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

Unexpected periodic fraction when substracting the integer from the single decimal place fraction #2856

Open
TokugawaTakeshi opened this issue Jan 29, 2024 · 3 comments

Comments

@TokugawaTakeshi
Copy link

TokugawaTakeshi commented Jan 29, 2024

To reproduce:

p(1.4 - 1)

Current behavior:

0.399999999999999

Expected behavior:

0.4

Environment information:

  • stylus version: 0.58.1
  • nodejs version: 18.13.0

If you can not fix this issue in the near future, please at least explain me why it occurs.
Depending on the cause, I'll write some workaround function.

@iChenLei
Copy link
Member

2024-01-29 19 14 56

Similar to the classical 0.1 + 0.2 issue, this is an inherent problem in JavaScript itself.

@vendethiel
Copy link
Contributor

This is an IEEE754 behavior

@TokugawaTakeshi
Copy link
Author

Thank you for the answer.
I'll close this issue soon, but before, would you please to share some links about this problem?

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