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

Feature request: divRound should be able to round up #79

Open
wanderer opened this issue Dec 9, 2015 · 2 comments
Open

Feature request: divRound should be able to round up #79

wanderer opened this issue Dec 9, 2015 · 2 comments

Comments

@wanderer
Copy link
Contributor

wanderer commented Dec 9, 2015

I need a way to round up the remained in division. Would that be a good option for divRound?

@wanderer
Copy link
Contributor Author

I don't need this anymore and don't have time to implement it ATM.

@axic
Copy link
Contributor

axic commented Nov 29, 2017

I'd like to reopen this. We found a need for divCeil in ethereumjs.

This is the current code we have:

 +// Find Ceil(`this` / `num`)
 +BN.prototype.divCeil = function divCeil (num) {
 +  var dm = this.divmod(num)
 +
 +  // Fast case - exact division
 +  if (dm.mod.isZero()) return dm.div
 +
 +  // Round up
 +  return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1)
 +}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants