1

I found that JavaScript performs an exact calculation when numbers are in safe integer range

Number.MIN_SAFE_INTEGER = -9007199254740991 = Math.pow(2, 53) - 1
Number.MAX_SAFE_INTEGER = 9007199254740991 = -(Math.pow(2, 53) - 1)

Is it possible to do calculation beyond this range without rounding off and losing precision?

Michel Floyd
  • 18,793
  • 4
  • 24
  • 39
Atulya
  • 153
  • 1
  • 11

2 Answers2

2

You may have to use something like big numbers. These numbers are represented as a string of decimal characters which are then operated by the library.

Check this out: StackOverflow link

Community
  • 1
  • 1
MarengoHue
  • 1,789
  • 13
  • 34
1

According to ECMAScript 6 there is no function to handle the specified operation. Even if we write a function for the same, I think we can't hold the value of the variable, which is to be computed with precision in js.

Rony Cherian
  • 114
  • 3