Skip to content

Instantly share code, notes, and snippets.

@ant358
Created January 6, 2022 15:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ant358/2247e440f83eabea9dcf41bf4e2c9b10 to your computer and use it in GitHub Desktop.
Save ant358/2247e440f83eabea9dcf41bf4e2c9b10 to your computer and use it in GitHub Desktop.
Truncate numbers (force them to round down)
def truncate(f, n=2):
return math.trunc(f * 10 ** n) / 10 ** n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment