nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨
https://nodejs.org
Other
107.64k stars 29.61k forks source link

BUG: Error calculation #8046

Closed Aminadav closed 8 years ago

Aminadav commented 8 years ago

Version: v5.6.0 Platform: Windows 64 (8)

See this output:

C:\>node
> 700/(1000*1000)*100
0.06999999999999999
>

From what I learn in highschool 700/(1000*10000)*100 = 0.07 not 0.0699....

vsemozhetbyt commented 8 years ago

@AminaG You will get the same result also in the Chrome or Firefox. It is not a bug in the Node.js or V8, it is a number representation issue in the JavaScript. See http://speakingjs.com/es5/ch11.html#rounding_errors (and the whole chapter for more context).