Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



It's not being validated. Validation and tests involving large numbers need to be added.


I 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.


>People still have to do financial calculations in JS.

No, they don't.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: