diff options
| author | Jannis Leidel <jannis@leidel.info> | 2011-04-22 12:03:10 +0000 |
|---|---|---|
| committer | Jannis Leidel <jannis@leidel.info> | 2011-04-22 12:03:10 +0000 |
| commit | 01d0bf011ef9c92892fa0717764d74ecfd2ef2b6 (patch) | |
| tree | 571a48ca2e6ce20a0c295815173c8b5f585e6c8e /django/utils/numberformat.py | |
| parent | 0e9692bc66ed7cfbbcb4c8031b36e82751685238 (diff) | |
Fixed #13810 -- Truncate numbers correctly when given number of decimal positions is zero. Thanks, milosu and Łukasz Rekucki.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16074 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/utils/numberformat.py')
| -rw-r--r-- | django/utils/numberformat.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py index 069f49851b..9597cdd063 100644 --- a/django/utils/numberformat.py +++ b/django/utils/numberformat.py @@ -2,7 +2,7 @@ from django.conf import settings from django.utils.safestring import mark_safe -def format(number, decimal_sep, decimal_pos, grouping=0, thousand_sep=''): +def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep=''): """ Gets a number (as a number or string), and returns it as a string, using formats definied as arguments: @@ -29,11 +29,11 @@ def format(number, decimal_sep, decimal_pos, grouping=0, thousand_sep=''): # decimal part if '.' in str_number: int_part, dec_part = str_number.split('.') - if decimal_pos: + if decimal_pos is not None: dec_part = dec_part[:decimal_pos] else: int_part, dec_part = str_number, '' - if decimal_pos: + if decimal_pos is not None: dec_part = dec_part + ('0' * (decimal_pos - len(dec_part))) if dec_part: dec_part = decimal_sep + dec_part # grouping |
