-
Notifications
You must be signed in to change notification settings - Fork 16
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 in reclaim escrow #281
Conversation
src/popup/pages/Send/index.js
Outdated
@@ -906,9 +906,9 @@ class SendPage extends React.Component { | |||
if(!isNumber(inputAmount) || !new BigNumber(inputAmount).gt(0)){ | |||
return 0 | |||
} | |||
const {amount ,shares} = this.props.nodeDetail | |||
const {amount, shares} = this.props.nodeDetail | |||
let sharePerAmount = new BigNumber(shares).dividedBy(amount).toString() |
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.
what precision does this division use?
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.
It defaults to 20 decimal places https://mikemcl.github.io/bignumber.js/#decimal-places
Good that you brought it up, BigNumber(inputAmount).multipliedBy(shares).dividedBy(amount)
would be better
src/popup/pages/Send/index.js
Outdated
let sharePerAmount = new BigNumber(shares).dividedBy(amount).toString() | ||
let realShare = new BigNumber(inputAmount).multipliedBy(sharePerAmount).toFixed(4,1).toString() | ||
let realShare = new BigNumber(inputAmount).multipliedBy(sharePerAmount).toFixed(cointypes.decimals, BigNumber.ROUND_DOWN) |
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.
here's one place we might not have to use ROUND_DOWN
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.
+1
1605893
to
ffa00c2
Compare
ffa00c2
to
c934260
Compare
This doesn't change reclaiming with ALL button, but still related to #165 and #153