[Tutor] Float number accuracy
motoom at xs4all.nl
Thu Jul 10 22:54:14 CEST 2008
On 10-jul-2008, at 22:41, Julia wrote:
> >>> c = 3.3
> >>> c
> 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
More information about the Tutor