-
Notifications
You must be signed in to change notification settings - Fork 45
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
Improve numeric precision with BigNumber.js #952
Conversation
/** | ||
* `<input max="9000000000.111111111">` warns about <=9000000000.11111 so we | ||
* round up to `<input max="9000000000.11112">` | ||
*/ | ||
const roundedUpStringifiedFloatMaxAmount = new BigNumber(props.maxAmount) | ||
.shiftedBy(-9) // / 10 ** 9 | ||
.toPrecision(15, BigNumber.ROUND_UP) |
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.
Chrome seems to parse <input max="..">
into a double-float, so we need to be round up when it hits the limit of double-float precision. Is there a good way to describe this operation? And a better way to implement it?
This implementation relies on double-float having at least 15 significant decimal digits.
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've heard other teams had to stop using <input type="number"
because of this.
@@ -76,8 +89,8 @@ export const ReclaimEscrowForm = memo((props: Props) => { | |||
placeholder={t('common.amount')} | |||
type="number" | |||
step="any" | |||
min={0.0001} | |||
max={Number(props.maxAmount) / 10 ** 9} | |||
min="0" |
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.
Is there some minimum amount for ReclaimEscrow?
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.
MegaLinter status: ✅ SUCCESS
See errors details in artifact MegaLinter reports on CI Job page |
Codecov Report
@@ Coverage Diff @@
## master #952 +/- ##
==========================================
+ Coverage 88.31% 88.49% +0.17%
==========================================
Files 97 98 +1
Lines 1678 1695 +17
Branches 388 390 +2
==========================================
+ Hits 1482 1500 +18
+ Misses 196 195 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
Fixes #436
Related #932 (comment)