Last active
August 29, 2015 13:55
-
-
Save carymrobbins/8742574 to your computer and use it in GitHub Desktop.
Round up in Python to specified digits.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import math | |
| def roundup(x, digits=0): | |
| n = 10**-digits | |
| return round(math.ceil(x / n) * n, digits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment