Fix for #14317 (number formatting issues) #348

wants to merge 1 commit into

3 participants


Fix based off the diff in
Please review @akaariai.

@berkerpeksag berkerpeksag commented on an outdated diff Sep 10, 2012
# Make the common case fast
if isinstance(number, int) and not use_grouping and not decimal_pos:
return mark_safe(six.text_type(number))
- # sign
- if float(number) < 0:
+ float_number = float(number)
+ str_number = six.text_type(number)
+ if decimal_pos is not None:
+ # Use the %f format string. This gives us rounding and the
+ # right number of decimal positions automatically. This also
+ # removes any 'e' if the number is really small or really large
+ str_number = six.text_type(('%.' + str(decimal_pos) + 'f') % (float_number))
berkerpeksag Sep 10, 2012
% (float_number)

Note: The parentheses are not required here.

Django member

Updated version of the patch is on the ticket.

@apollo13 apollo13 closed this May 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment