Created
September 25, 2012 23:56
-
-
Save SecurityForUs/3785180 to your computer and use it in GitHub Desktop.
Workaround from using Math functions
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
def fmt_currency(val): | |
tmp = val | |
if not isinstance(tmp, str): | |
tmp = str(tmp) | |
if val < 100: | |
cents = tmp | |
dollars = "0" | |
else: | |
cents = tmp[-2:] | |
dollars = tmp[0:len(tmp)-2] | |
return "%s.%s" % (dollars, cents) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment