Replies: 1 comment
-
|
Are you trying to round or take the ceiling? 1.05 will always round to one. 1.45 will round to 1. 1.5 will round to 2 in numeric systems that support rounding, and for the correct rounding strategy. What you are interested in is using the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have a use case where I need to divide
105with100using ether.js BigNumber (it's not really105, it's a much larger number than that). The result is1.05but because I'm usingBigNumberthat rounds down to1.The issue I'm facing is that I need this division to always round up, instead of rounding down, so I implemented the following workaround:
Essentially, this function uses the
modfunction to check for a remainder, and if there is any, it increases the result in1.I understand that ether.js BigNumber uses
bn.jsunder the hood, does it make sense to exposebn.jsfunctiondivRoundto support rounded divisions?Beta Was this translation helpful? Give feedback.
All reactions