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

toWei: incorrect result for small numbers (< 1e-6) #6

Open
1 of 2 tasks
slavafomin opened this issue Jun 2, 2022 · 1 comment
Open
1 of 2 tasks

toWei: incorrect result for small numbers (< 1e-6) #6

slavafomin opened this issue Jun 2, 2022 · 1 comment

Comments

@slavafomin
Copy link

slavafomin commented Jun 2, 2022

Issue Type

Description

The toWei() function will return incorrect results when passing numbers smaller than 1e-6 to it.

For example toWei(1e-7, 'gwei').toString() will return 2377000000000 instead of 100.

The issue starts here and then cascades downward. The problem is that you are using the String constructor to convert number to a string. However, it will produce some small numbers in exponential notation instead of the fixed notation that you are expecting.

Steps to reproduce

Check the PR #7.

Versions

Doesn't matter.

@slavafomin
Copy link
Author

Check the PR #7 for a fix.

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