This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: float formatting error?
Type: behavior Stage: resolved
Components: Versions: Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: johngholman, rhettinger
Priority: normal Keywords:

Created on 2022-01-04 18:09 by johngholman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg409696 - (view) Author: John Holman (johngholman) Date: 2022-01-04 18:09
Example:

str(10000.12345678901234)
Out[24]: '10000.123456789011'

shouldn't the last digit should be 2?
msg409698 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2022-01-04 18:17
The two numbers you gave become the same when rounded to the limited internal precision used by floats.

>>> 10000.12345678901234 == 10000.123456789011
True

When it comes to displaying the number, Python tries to show the shortest possible member of the equivalence class.
msg409699 - (view) Author: John Holman (johngholman) Date: 2022-01-04 18:20
Thanks - sorry to waste your time.

On Tue, 4 Jan 2022 at 18:17, Raymond Hettinger <report@bugs.python.org>
wrote:

>
> Raymond Hettinger <raymond.hettinger@gmail.com> added the comment:
>
> The two numbers you gave become the same when rounded to the limited
> internal precision used by floats.
>
> >>> 10000.12345678901234 == 10000.123456789011
> True
>
> When it comes to displaying the number, Python tries to show the shortest
> possible member of the equivalence class.
>
> ----------
> nosy: +rhettinger
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <https://bugs.python.org/issue46259>
> _______________________________________
>
History
Date User Action Args
2022-04-11 14:59:54adminsetgithub: 90417
2022-01-04 18:20:18johngholmansetmessages: + msg409699
2022-01-04 18:17:18rhettingersetstatus: open -> closed

nosy: + rhettinger
messages: + msg409698

resolution: not a bug
stage: resolved
2022-01-04 18:09:08johngholmancreate