On 10-jul-2008, at 22:41, Julia wrote:
>>> c = 3.3
>>> c
3.2999999999999998
I've done it with and without the c = float and still it rounds the
number down. Why? And more importantly: is it possible to make
Python more accurate? I need the exact number and not something
close to it for my new application.
That's because floats have only a fixed amount of bits to represent
values, and not all values can be represented exactly, so there
occurs some rounding errors.
Python can do exact math using the 'decimal' package. See
http://www.python.org/doc/2.4.3/lib/module-decimal.html
Greetings,
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor