What's the big deal with getting bignum into js? Everything else I can agree with, but not having 64bit int support in a server side language has to hurt. (just look at most node db adapters and bigints are handled as strings)
0.3 * 3 => 0.8999999999999999
A few rounding mistakes and you have a huge mess.And the example you have given is a problem with all floating point implementations, not just Javascript. You will get that exact same answer in C, Java, etc.
The only way to avoid this is to represent rational numbers directly, without simplification. For example:
(3/10) * 3 => (9/10)In the example given, using node-bignum and assuming our precision is a thousand of a cent:
big(30000).mul(3) => 90000
Of course you'd get the same result in plain javascript with these numbers, but then you'd have to handle everywhere an operation could return decimals, and using bignum you have "unlimited" precision > 52bits.Here's a relevant example,
2^26 * 2^26 == 2^52
may not hold in javascript because it only supports 52 significant binary digits. Whereas other languages usually support 64 significant binary digits.that said, you could still write your own bigint class if you need precision beyond that.