I get the strangest result when I multiply 1.09 and 12. Actually 13.080000000000002 instead 13.08!!! What causes this? nd what is the solution
console.log(1.09*12);
Regards.
I get the strangest result when I multiply 1.09 and 12. Actually 13.080000000000002 instead 13.08!!! What causes this? nd what is the solution
console.log(1.09*12);
Regards.
As explained here:
In JavaScript all numbers are IEEE 754 floating point numbers. Due to the binary nature of their encoding, some decimal numbers cannot be represented with perfect accuracy. This is analagous to how the fraction 1/3 cannot be accurately represented with a decimal number with a finite number of digits. Once you hit the limit of your storage you'll need to round the last digit up or down.