javascript - Multiply returns a strange result -
this question has answer here:
- is floating point math broken? 20 answers
- how deal floating point number precision in javascript? 33 answers
i strangest result when multiply 1.09 , 12. 13.080000000000002 instead 13.08!!! causes this? nd solution
console.log(1.09*12);
regards.
as explained here:
in javascript numbers ieee 754 floating point numbers. due binary nature of encoding, decimal numbers cannot represented perfect accuracy. analagous how fraction 1/3 cannot accurately represented decimal number finite number of digits. once hit limit of storage you'll need round last digit or down.
Comments
Post a Comment