Skip to content

Instantly share code, notes, and snippets.

@carymrobbins
Last active August 29, 2015 13:55
Show Gist options
  • Save carymrobbins/8742574 to your computer and use it in GitHub Desktop.
Save carymrobbins/8742574 to your computer and use it in GitHub Desktop.
Round up in Python to specified digits.
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