Skip to content

Instantly share code, notes, and snippets.

@philippeowagner
Last active December 22, 2015 08:18
Show Gist options
  • Select an option

  • Save philippeowagner/6444070 to your computer and use it in GitHub Desktop.

Select an option

Save philippeowagner/6444070 to your computer and use it in GitHub Desktop.
from decimal import Decimal
def roundTo5(value):
'''
Rounds to the nearest 5 swiss franc cents and appends zeros to get a pretty value back.
'''
return (Decimal(str(round(Decimal(str(value))*Decimal("20"))))/Decimal("20")).quantize(Decimal('1.00'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment