Ticket #13810: number_format.patch

File number_format.patch, 790 bytes (added by milosu, 14 years ago)
  • django/utils/numberformat.py

     
    2626            dec_part = dec_part[:decimal_pos]
    2727    else:
    2828        int_part, dec_part = str_number, ''
    29     if decimal_pos:
     29    # allow decimal_pos = 0, i.e. no decimal part
     30    if decimal_pos >= 0:
    3031        dec_part = dec_part + ('0' * (decimal_pos - len(dec_part)))
     32        # truncate decimal part, if required
     33        if len(dec_part) > decimal_pos and decimal_pos >= 0:
     34            dec_part = dec_part[0:decimal_pos]
    3135    if dec_part: dec_part = decimal_sep + dec_part
    3236    # grouping
    3337    if settings.USE_L10N and settings.USE_THOUSAND_SEPARATOR and grouping:
Back to Top