There are significant issues with floats. To start with, float precision varies based on the number considered. The typical distance between consecutive two large floats is much larger than the typical distance between two floats close to 0. This can lead to surprising behavior.
-
-
Show this thread
-
And importantly, floats can't accurately represent base 10 numbers used for large quantities, like money. A 10e10 float is actually smaller than 10e10, for instance. Even 0.7 float is actually smaller than 0.7.
Show this thread -
This means floats lead to weird numerical discrepancies that accumulate as you add more operations. Only use floats if you want to run large computation with approximate numbers -- scientific computing, basically.
Show this thread
End of conversation
New conversation -
-
-
We lost the decimal number when se moved from the mainframe to Unix and we’ll pay for it forever.
-
Python stdlib has the decimal and fraction modules
End of conversation
New conversation -
-
-
Should float be changed to multiples of Planck constant?
-
The fact that floats use an exponent representation instead of a fixed quantization step is actually their strength. Just don't use floats when you need fixed quantization.
End of conversation
New conversation -
-
-
19 year old here, I don’t understand how you would store something like cash if in an int? Do you just store $19.50 as 1950?
-
Yes exactly this. Some applications, such as accountancy services and stock exchanges use 4 decimal places instead.
- Show replies
New conversation -
-
-
True
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.