4 ms·
Floats are outrageously complicated. Tread carefully! If you ever deal with the nitty gritty of floating point numbers you should read every post on the topic o
by forrestthewoods 14y ago
Floats are outrageously complicated. Tread carefully! If you ever deal with the nitty gritty of floating point numbers you should read every post on the topic on Bruce Dawson's blog. It's up to 15 posts long.
TLDR - if you think you know all there is to know about floats then you're wrong. Read on!
http://randomascii.wordpress.com/2013/02/07/float-precision-revisited-nine-digit-float-portability/ http://randomascii.wordpress.com/2013/02/07/float-precision-... (has links to all posts in series)
- GhotiFish 14y agoThanks for the link. I think floats are pretty overused, I don't see fixed precision decimals getting used, which always struck me as odd.
- zokier 14y agoI'd love to see a language or even a library that would make no-surprise fixed point and/or arbitrary precision math first class citizens, like what Python did with integers.
- dlitz 14y agoPython has a decimal (as opposed to binary) floating-point library, which is great for doing math with inherently decimal quantities (e.g. money): http://docs.python.org/3.3/library/decimal.html http://docs.python.org/3.3/library/decimal.html
- whattssonn 14y agoCOBOL and RPG, for example, on Mainframe / Midrange systems have native support for fixed point (decimal) types. It's the second most used type, besides the "character" types. Floats are seldom used in the context of business applications. Fixed point math is even directly implemented in hardware on Power processors. Always been like that on IBM platforms.