when I run the number 361741715964559368 into .toString() I get "361741715964559360" back, the last number is 0 for some reason, same thing happens when i just do +""
I tried updating node, didnt fix the problem
361741715964559368 exceeds the range of integers that can be exactly described with a IEEE 754 binary64 number (in other words, a double), which is what JavaScript number type is, as it is greater than Number.MAX_SAFE_INTEGER or 9007199254740991. This is not a problem exclusive to Node.js, but is in fact part of the language itself (you can replicate this in all browsers).
The upcoming BigInt proposal would allow exact expression of this number. But for now, there is no way to deal with this imprecision, except using some userland third-party modules (1 2 3 4 5 6).
Answered, closing.
Most helpful comment
361741715964559368 exceeds the range of integers that can be exactly described with a IEEE 754 binary64 number (in other words, a double), which is what JavaScript number type is, as it is greater than
Number.MAX_SAFE_INTEGERor 9007199254740991. This is not a problem exclusive to Node.js, but is in fact part of the language itself (you can replicate this in all browsers).The upcoming BigInt proposal would allow exact expression of this number. But for now, there is no way to deal with this imprecision, except using some userland third-party modules (1 2 3 4 5 6).