Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistake in calculations #15475

Closed
Reza1607 opened this issue Sep 19, 2017 · 2 comments
Closed

Mistake in calculations #15475

Reza1607 opened this issue Sep 19, 2017 · 2 comments

Comments

@Reza1607
Copy link

Hello
When calculating the following, the calculation is wrong

> console.log(.58*100)
57.99999999999999  // !!!!!!!!
> console.log(.57*100)
56.99999999999999  // !!!!!!!!
> console.log(.56*100)
56.00000000000001  // !!!!!!!!
> console.log(.55*100)
55.00000000000001  // !!!!!!!!
> console.log(.54*100)
54
> console.log(.53*100)
53
> console.log(.52*100)
52

Why?

  • Version: 7.5.0
  • Platform: Linux 4.10.0-35-generic Gitter chat room? #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
@apapirovski
Copy link
Member

Hi @Reza1607, this is a common problem in languages that implement IEEE 754 floating-point arithmetic. See this handy site for more info: http://floating-point-gui.de/ and more specifically http://floating-point-gui.de/basic/

In general, the appropriate place to ask this question would be in https://github.com/nodejs/help or StackOverflow. This tracker is for bug reports and feature requests related to Node core.

@tniessen
Copy link
Member

Similar issues have been reported numerous times and are present in all languages implementing IEEE 754 floating point numbers. Arbitrary precision arithmetic is not supported at the moment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants