#28280: numberformat.format does not handle scientific notation correctly
---------------------------+------------------------------------
     Reporter:  Wil Tan    |                    Owner:  nobody
         Type:  Bug        |                   Status:  new
    Component:  Utilities  |                  Version:  1.11
     Severity:  Normal     |               Resolution:
     Keywords:             |             Triage Stage:  Accepted
    Has patch:  0          |      Needs documentation:  0
  Needs tests:  0          |  Patch needs improvement:  0
Easy pickings:  0          |                    UI/UX:  0
---------------------------+------------------------------------
Changes (by Tim Graham):

 * component:  Uncategorized => Utilities
 * type:  Uncategorized => Bug
 * stage:  Unreviewed => Accepted


Old description:

> For floats with values larger than 1e16 or smaller than 1e-5, their
> string representation uses scientific notation in Python, which causes
> {{{numberformat.format}}} to return an erroneous output.
>
> {{{
> >>> format(0.0000000000000000009, '.', 2)
> '9e-19.00'
> >>> format(1e16, '.', 2, thousand_sep=',', grouping=3,
> force_grouping=True)
> '1e,+16.00'
> }}}
>
> This is similar to #23935 but that was only fixed for Decimal types.

New description:

 For floats with values larger than 1e16 or smaller than 1e-5, their string
 representation uses scientific notation in Python, which causes
 {{{numberformat.format}}} to return an erroneous output.

 {{{
 >>> from django.utils.numberformat import format
 >>> format(0.0000000000000000009, '.', 2)
 '9e-19.00'
 >>> format(1e16, '.', 2, thousand_sep=',', grouping=3,
 force_grouping=True)
 '1e,+16.00'
 }}}

 This is similar to #23935 but that was only fixed for Decimal types.

--

--
Ticket URL: <https://code.djangoproject.com/ticket/28280#comment:1>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.7bfb75fd0cc84670adf325468ef4010f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to