Last active
June 26, 2018 03:55
-
-
Save azengard/59545f5791d21660955206e3a6926514 to your computer and use it in GitHub Desktop.
This file contains 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
from math import ceil, floor | |
def round_2_down(number): | |
"""Arredonda 2 casas sempre para baixo""" | |
if number < 0: | |
return ceil(number * 100)/100 | |
return floor(number * 100)/100 | |
def round_n_down(number, digits=2): | |
"""Arredonda n casas sempre para baixo""" | |
if number < 0: | |
return ceil(number * pow(10, digits))/pow(10, digits) | |
return floor(number * pow(10, digits))/pow(10, digits) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment