Floating point problem

Aakash Jana aakashjana2002 at gmail.com
Sat Apr 18 11:09:48 EDT 2020


I am really enlightened by the amount of knowledge I received from a
question that seemed so little to me. 😅

On Sat, 18 Apr 2020, 8:08 pm Souvik Dutta <souvik.viksou at gmail.com wrote:

> Hmm understood.
>
> Souvik flutter dev
>
> On Sat, Apr 18, 2020, 7:36 PM Chris Angelico <rosuav at gmail.com> wrote:
>
> > On Sun, Apr 19, 2020 at 12:03 AM Souvik Dutta <souvik.viksou at gmail.com>
> > wrote:
> > >
> > > I literally tried it!!! And it did not stop because I did not get any
> 1.0
> > > rather I got 0.99999999999 But why does this happen. This is a simple
> > math
> > > which according to normal human logic should give perfect numbers which
> > are
> > > not endless. Then why does a computer behave so differently?
> > >
> >
> > If you add 0.333 and 0.333 and 0.333, do you get 1.0? No, you get
> > 0.999. But if you add 1/3 and 1/3 and 1/3, you get 1. The computer has
> > to round, same as you do - it doesn't have infinite precision. The
> > truth is that the number 0.1, to a computer, is not actually one tenth
> > - it's an approximation for one tenth, just as 0.333 is an
> > approximation for one third.
> >
> > ChrisA
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >
> --
> https://mail.python.org/mailman/listinfo/python-list
>


More information about the Python-list mailing list