Skip to content
Advertisement

Something wrong with BigInteger

JavaScript

when i test this function with base16 :F0F0F0F0F0F0F0, it return right result = 67818912035696880 BUT when i test with base16: F0F0F0F0F0F0F0F0, it returns wrong result: 17361641481138401580 which right result must be 17361641481138401520 please help me!

Advertisement

Answer

Math.pow delivers a double, 8 bytes. So from some huge double value, it becomes imprecise in the less significant digits.

You could have used

JavaScript

The repair is:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement