[Python-ideas] Hexadecimal floating literals
Guido van Rossum
guido at python.org
Fri Sep 22 11:37:31 EDT 2017
More information about the Python-ideas mailing list
Fri Sep 22 11:37:31 EDT 2017
- Previous message (by thread): [Python-ideas] Hexadecimal floating literals
- Next message (by thread): [Python-ideas] Hexadecimal floating literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Thu, Sep 21, 2017 at 9:20 PM, Nick Coghlan <ncoghlan at gmail.com> wrote: > >>> one_tenth = 0x1.0 / 0xA.0 > >>> two_tenths = 0x2.0 / 0xA.0 > >>> three_tenths = 0x3.0 / 0xA.0 > >>> three_tenths == one_tenth + two_tenths > False > OMG Regardless of whether we introduce this feature, .hex() is the way to show what's going on here: >>> 0.1.hex() '0x1.999999999999ap-4' >>> 0.2.hex() '0x1.999999999999ap-3' >>> 0.3.hex() '0x1.3333333333333p-2' >>> (0.1+0.2).hex() '0x1.3333333333334p-2' >>> This shows so clearly that there's 1 bit difference! -- --Guido van Rossum (python.org/~guido <http://python.org/%7Eguido>) -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170922/26c4ba0a/attachment-0001.html>
- Previous message (by thread): [Python-ideas] Hexadecimal floating literals
- Next message (by thread): [Python-ideas] Hexadecimal floating literals
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-ideas mailing list