javascript - Multiply returns a strange result -


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

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -