Jan Rüegg is right - this is just how floats work.
If you're wondering why this only shows up with c_float
, it's because
c_float
s print as "c_float({!r}).format(self.value)
. self.value
is a double-precision Python float.
Python's float
type prints the shortest representation that converts to the floating point number, so although float(0.2)
is not exact it can still be printed in short form.
The inaccuracy in c_float(0.2)
is high enough to make it closer to
0.20000000298023223876953125
than to
0.200000000000000011102230246251565404236316680908203125
Since float(0.2)
represents the later, the short form of "0.2"
cannot be used.