array precision

Jason Orendorff jason at jorendorff.com
Tue Feb 5 19:38:51 EST 2002


Hugo Martires writes:
> suposing that n=10 we get: myArray[0] = 0.600000023 ("something 
> like this")
> 
> but if i do: myArray[i] + (1.0/n) it give's me 0.6
> 
> what's the problem of the array, and how can i solve this ?

It's only half of the normal precision.  From the documentation:

    The following type codes are defined:
        Type code   C Type             Minimum size in bytes
        'f'         floating point     4
        'd'         floating point     8

Try using 'd' instead of 'f'.

## Jason Orendorff    http://www.jorendorff.com/




More information about the Python-list mailing list