Skip to content Skip to sidebar Skip to footer

Difference Between Real Calculation Number And The One I Calculate With Javascript Function

This is the function that I write for exponentiation like the Math.pow function in JavaScript. Code: function tavan(){ var adad=document.getElementById('pain').value; var tavan=doc

Solution 1:

The floating point format used in Javascript has 56 bits of mantissa. To store 4^28 accurately requires 57 bits. So the least significant bit is dropped and the exponent is increased, and you get an approximate result.

The Windows calculator probably uses arbitrary precision integer math, which allows it to show larger numbers precisely. See:

What is the standard solution in Javascript for handling big numbers (BigNum)?

for similar libraries for Javascript.

Post a Comment for "Difference Between Real Calculation Number And The One I Calculate With Javascript Function"