Floating point problem

ast ast at invalid
Sat Apr 18 12:04:43 EDT 2020


Le 18/04/2020 à 15:07, Souvik Dutta a écrit :
> I have one question here. On using print(f"{c:.32f}") where c= 2/5 instead
> of getting 32 zeroes I got some random numbers. The exact thing is
> 0.40000000000000002220446049250313
> Why do I get this and not 32 zeroes?
> 



2/5 = 0.0110011001100110011001...  and repeat 1001 infinitely

It cannot be represented exactly on a 64bits float






More information about the Python-list mailing list