Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Javascript - Calculation Error [duplicate]

Tags:

javascript

In the Chrome Javascript Console I type the following:

3.1 * 3.68

And the result returned is:

11.408000000000001

Why is the result not:

11.408
like image 729
freshest Avatar asked Dec 03 '10 13:12

freshest


1 Answers

Floating point errors are quite normal, this is due to the problems inherent in representing some floating point numbers in binary.

Read this: What Every Computer Scientist Should Know About Floating-Point Arithmetic.

like image 112
Oded Avatar answered Sep 19 '22 00:09

Oded