[Python-Dev] FixedPoint and % specifiers.
Tim Peters
tim.one@comcast.net
Wed, 05 Feb 2003 20:13:40 -0500
[Guido]
> Eh? In C as well as Python, %d means decimal *integer*. The format
> specifier to use fixed point notation is %f.
>
> Please don't change this!
I sure wouldn't <wink>. Note that use of %f ends up calling
FixedPoint.__float__(), though, and so sucks users right back into binary fp
surprises:
>>> t = FixedPoint.FixedPoint(".1")
>>> print t
0.10
>>> print "%.17f" % t
0.10000000000000001
>>> float(t) == 0.1
True
>>>
FixedPoint does the best possible job of converting 1/10 to a float, but
it's exactly as surprising as the float literal 0.1 then.