-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Fix towei scientific notation #6908
Conversation
Bundle StatsHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Benchmark
This comment was automatically generated by workflow using github-action-benchmark. |
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## 4.x #6908 +/- ##
==========================================
+ Coverage 91.97% 91.98% +0.01%
==========================================
Files 215 215
Lines 8273 8284 +11
Branches 2268 2272 +4
==========================================
+ Hits 7609 7620 +11
Misses 664 664
Flags with carried forward coverage won't be shown. Click here to find out more.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is better to not show a warning nor throw an exception. I think we just need to check in this line if the value is less than the minimum acceptable floating point number, and use BigInt in that case. So, I suggest to simply do it similar to how we currently handle for large numbers. Or what do you think?
...conversionBaseData, | ||
[['255', 'wei'], '0xFF'], | ||
[['255', 'wei'], '0xFF'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is doublicate. Was it meant to have differnt values? Or, should this be deleted?
if (parsedNumber < 1e-15){ | ||
console.warn(PrecisionLossWarning) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering, why this is no need to call parsedNumber = BigInt(parsedNumber);
here similar to the logic for parsedNumber < 1e-15
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large decimal numbers values become scientific notation (for example 1e-15
) and scientific notation is not accepted by BigInt. On line 573 we will convert the number to a string, so there is no need to convert to a bigint
Description
#6894
Please include a summary of the changes and be sure to follow our Contribution Guidelines.
Type of change
Checklist:
npm run lint
with success and extended the tests and types if necessary.npm run test:unit
with success.npm run test:coverage
and my test cases cover all the lines and branches of the added code.npm run build
and testeddist/web3.min.js
in a browser.CHANGELOG.md
file in the root folder.