Floating point problem

Souvik Dutta souvik.viksou at gmail.com
Sat Apr 18 09:07:09 EDT 2020


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?

On Fri, 17 Apr, 2020, 6:25 pm ast, <ast at invalid> wrote:

> Le 17/04/2020 à 13:40, Aakash Jana a écrit :
>
> > I am running python 3.8 only but my issue is I need more zeroes after my
> > result.
> > I want 2/5 = 0.400000
> > But I am only getting 0.4
>
> f"{2/5:.6f}"
> '0.400000'
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list