Author tim.peters
Recipients alexandre.vassalotti, amaury.forgeotdarc, christian.heimes, gvanrossum, mark.dickinson, nascheme, noam, rhettinger, skip.montanaro, tim.peters
Date 2008-07-04.01:02:26
SpamBayes Score 0.000836202
Marked as misclassified No
Message-id <1215133348.35.0.867053922521.issue1580@psf.upfronthosting.co.za>
In-reply-to
Content
If you think using 16 (when possible) will stop complaints, think again
;-)  For example,

>>> for x in 0.07, 0.56:
...     putatively_improved_repr = "%.16g" % x
...     assert float(putatively_improved_repr) == x
...     print putatively_improved_repr
0.07000000000000001
0.5600000000000001

(those aren't the only "2-digit" examples, but I expect those specific
examples work the same under Linux and Windows).

IOW, 16 doesn't eliminate base-conversion surprises, except at the 8
"single-digit surprises" (i/10.0 for i in range(1, 5) + range(6, 10)).

To eliminate "2-digit surprises" (like 0.07 and 0.56 above), and higher,
 in this way, you need to add a loop and keeping trying smaller
conversion widths so long as they convert back to the original input.

Keep it up, and you can make repr(float) so slow it would be faster to
do perfect rounding in Python ;-)
History
Date User Action Args
2008-07-04 01:02:29tim.peterssetspambayes_score: 0.000836202 -> 0.000836202
recipients: + tim.peters, gvanrossum, skip.montanaro, nascheme, rhettinger, amaury.forgeotdarc, mark.dickinson, christian.heimes, alexandre.vassalotti, noam
2008-07-04 01:02:28tim.peterssetspambayes_score: 0.000836202 -> 0.000836202
messageid: <1215133348.35.0.867053922521.issue1580@psf.upfronthosting.co.za>
2008-07-04 01:02:27tim.peterslinkissue1580 messages
2008-07-04 01:02:26tim.peterscreate