0

I created a component to calculate the power of numbers but the problem is Number.MAX_SAFE_INTEGER. how can I calculate a larger number like 5^200 in my app completely without rounding?

Math.pow(5,200) // it loged `infinity`
hossein fti
  • 900
  • 1
  • 6
  • 12
  • You can try using a BIGINT library. Or you could, alternatively, do calculations on "strings" with your own algorithms if no other library suffices. If you use a "string" approach, there is no limit other than max string length, on precision. – mardubbles May 22 '22 at 19:09
  • Can you use the `BigInt` object? https://betterprogramming.pub/using-javascript-bigint-to-represent-large-numbers-d1ad9f6e0079 – blurfus May 22 '22 at 19:09

0 Answers0