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

Rounding issues and unsafe operations #11

Open
tujlaky opened this issue Jul 21, 2023 · 1 comment
Open

Rounding issues and unsafe operations #11

tujlaky opened this issue Jul 21, 2023 · 1 comment

Comments

@tujlaky
Copy link

tujlaky commented Jul 21, 2023

I think this line in the implementation is not safe it could cause rounding issues:

https://github.com/uzyn/bigdenary/blob/master/mod.ts#L31C7-L31C60

For example the following number will fail: 0.0023537

You can see the problem with this if you try the following calculation:

// 23536.999999999996 instead of 23537
0.0023537 * Math.pow(10, 7)

The response will be a float instead of an integer so it will fail with BigInt.

@tujlaky tujlaky changed the title Rounding issues Rounding issues and unsafe operations Jul 21, 2023
@tujlaky
Copy link
Author

tujlaky commented Jul 21, 2023

You will see the following JS error:

RangeError - The number 23536.999999999996 cannot be converted to a BigInt because it is not an integer

Repository owner deleted a comment from liMike1998 Feb 23, 2024
@github-staff github-staff deleted a comment Apr 26, 2024
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

1 participant