Skip to content

Instantly share code, notes, and snippets.

@azengard
Last active June 26, 2018 03:55
Show Gist options
  • Save azengard/59545f5791d21660955206e3a6926514 to your computer and use it in GitHub Desktop.
Save azengard/59545f5791d21660955206e3a6926514 to your computer and use it in GitHub Desktop.
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