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: Wrong dump of floats
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 2.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: ezio.melotti, r.david.murray, stein
Priority: normal Keywords:

Created on 2009-03-28 18:58 by stein, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg84323 - (view) Author: Sebastian Billaudelle (stein) Date: 2009-03-28 18:58
Hi there,

I just recognized a weird behaviour of the json module...

Dumpig a float like 0.1 I get some crazy output.

Here is an example:

>>> import json
>>> json.dumps([.1])
'[0.10000000000000001]'

Very simple to reproduce;)

- Sebastian
msg84324 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-03-28 19:06
>>> .1
0.10000000000000001

Read http://docs.python.org/tutorial/floatingpoint.html
msg84327 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-03-28 19:16
As Ezio points out, this is correct Python behavior.
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49839
2009-06-25 13:33:22amaury.forgeotdarcunlinkissue6342 dependencies
2009-06-25 13:30:09r.david.murraylinkissue6342 dependencies
2009-03-28 19:18:22benjamin.petersonsetstatus: open -> closed
2009-03-28 19:16:12r.david.murraysetnosy: + r.david.murray
messages: + msg84327

components: + Interpreter Core, - Library (Lib)
resolution: not a bug
stage: resolved
2009-03-28 19:06:54ezio.melottisetnosy: + ezio.melotti
messages: + msg84324
2009-03-28 18:58:35steincreate