Skip to content

Instantly share code, notes, and snippets.

@mrchilds
Created April 16, 2012 13:59
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 mrchilds/2399003 to your computer and use it in GitHub Desktop.
Save mrchilds/2399003 to your computer and use it in GitHub Desktop.
Python and Money
Work out total and then round up to 2 decimal places WITHOUT dropping the final zero....
from decimal import *
cost = "12.56896"
cost = Decimal(cost).quantize(Decimal('.01'), rounding=ROUND_UP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment