Javascript long integer

In Java, you have 64 bits integers, and that’s what you’re using.

In JavaScript, all numbers are 64 bits floating point numbers. This means you can’t represent in JavaScript all the Java longs. The size of the mantissa is about 53 bits, which means that your number, 793548328091516928, can’t be exactly represented as a JavaScript number.

If you really need to deal with such numbers, you have to represent them in another way. This could be a string, or a specific representation like a digit array. Some “big numbers” libraries are available in JavaScript.

Leave a Comment