3 ms·
A 64 bit floating point number can still represent exactly all integers smaller than 2^53 so it’s possible to use that for constructing proper rationals or doin
by alkonaut 9y ago
A 64 bit floating point number can still represent exactly all integers smaller than 2^53 so it’s possible to use that for constructing proper rationals or doing proper exact comparisons and currency calculations within certain bounds e.g by using 1/100000 dollars as the unit you can fit any amount under 2^48.
It’s terrible to not even have proper integers but that doesn’t make the problem go away. People still have to do financial calculations in JS.
- partycoder 9y agoIt's not being validated. Validation and tests involving large numbers need to be added.
- alkonaut 9y agoI didn’t look at the details of this specific library (which I expect is even more complex than just using the exact integers of ieee754). But yes - in order to properly use the exact integers, the number would have to be encapsulated in an object and validated (range, dropping decimals, returning optional values for things that might fail etc). You can not just take two “Number” and use for proper decimal math without enforcing some invariants.
- tzahola 9y ago>People still have to do financial calculations in JS. No, they don't.
- deleted 9y ago[deleted]