3 ms·
I know what floating point is. I've implemented it in hardware. I've implemented it in software. But you know what? Floating point is not the only way peopl
by jstewartmobile 8y ago
I know what floating point is. I've implemented it in hardware. I've implemented it in software. But you know what? Floating point is not the only way people have ever represented real numbers on the computer.
In most SQLs, decimal fixednum types are predominant. Most LISPs have a number tower that automatically juggles fixnums, bignums, ratios, floats, and complex numbers. In the 8/16-bit days--before everything had a floating-point unit--it was not uncommon to store and calculate numbers directly in BCD. Two-digits to the byte, and all of the operations--including formatting--were very straightforward to implement. Many of the old business mainframes even have hardware instructions to pack/unpack/operate on BCD.
> that most users of programming languages don't want to keep track of that...
Why would I want to keep track of that when the language (or more accurately, the data type) will do it for me?
I'm sorry man. The whole world isn't C and JavaScript (yet). That we have forced crud-app developers to resort to garbage like this[0]--in places where the performance and storage benefits of floating-point are irrelevant--is a stain on the profession.
[0] http://www.jacklmoore.com/notes/rounding-in-javascript/ http://www.jacklmoore.com/notes/rounding-in-javascript/