Skip to the content ForoHackers
Log inJoin

0.1 + 0.2 gives my cycling app a little tail. Do I ride the tail?

Numerical analysisPython
#8454 · · Quote · Report

I put two stretches of bike path into Python, 0.1 km and 0.2 km, and got 0.30000000000000004. I'm not cycling the last bit. I'm already home.

#8506 · · Quote · Report

half a kilometre and a quarter, pls. I'd love to see what your bicycle does with a number that fits.

#8507 · · Quote · Report

@calisto_no 0.75. well that was inconvenient for my theory that every number has an arse.

#8508 · · Quote · Report

El medio y el cuarto son sumas finitas de potencias de dos. Una décima se queda dando vueltas en binario, como un tercio escrito en decimal. Hay que redondear para guardarla.

#8509 · · Quote · Report

The Python explanation lets you see the exact fraction in storage. For a sign saying how far you rode, format the result for the reader. If the rules of your game require decimal tenths exactly, count tenths as integers or start with Decimal("0.1").

#8510 · · Quote · Report

Sign now says 300 metres. Bet somebody takes a tape to the path and gets 298. Different complaints department, mate.

#8564 · · Quote · Report

A mi crío le salen dos vueltas de 2 km y un total de 5. Me dice que la bici suma mejor que yo. Eran 2,5 km cada una, joder, tengo público para estas cosas.

#8565 · · Quote · Report

En Python, con esos valores, round(2.5) + round(2.5) da 4 y round(2.5 + 2.5) da 5. Aquí 2,5 sí cabe exacto en binario. Lo que te cambia el total es redondear dos veces en sitios distintos.

#8566 · · Quote · Report

Ya pero al que mira la pantalla qué le decimos, ¿"según la jurisdicción"? Si te cabe "2 km" en cada fila te cabe "2,5". Los km arriba y nos quitamos la toga.

#8567 · · Quote · Report

Le di la pantalla a mi sobrino sin decirle por qué. "¿Y la media de cada vuelta pa quién es?" Ya podéis cerrar mi departamento. Voy a poner los metros en la lista y los km arriba.

#8572 · · Quote · Report

Lol I came in here to complain about too MANY digits. Can we park our bikes next to each other and get one average bike

You are not logged in, so this goes up anonymously: no account, no name and no address is stored with it, and it may carry no link and no image. Log in or join to post under your name. Our web server's logs keep the address and time of every request for up to 14 days; to keep yours out of them, use Tor. To reach the staff in confidence, use the drop. Sign as a returning source (a key kept only in this browser)

Sending takes a few seconds here: your browser first works out a proof of work against spam.

Reply