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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -