[Tutor] float.is_integer()

Zachary Ware zachary.ware+pytut at gmail.com
Fri Oct 2 20:08:16 EDT 2020


Have a look at the repr of 23444444444444444.7777; a 64 bit floating point
number cannot represent that number exactly.

--
Zach
(On a phone)

On Fri, Oct 2, 2020, 18:20 Alan Gauld via Tutor <tutor at python.org> wrote:

> On 02/10/2020 18:07, Manprit Singh wrote:
>
> >>>> (23444444444444444.7777).is_integer()
> > True
>
> How weird. I get the same result and the documentation is so
> sparse that it's of no real help.
>
> Hopefully somebody else can shed some light on it.
> Or maybe you've actually found a bug! But I suspect the answer
> will lie in one of those odd binary level features of floats...
> But too subtle for me!
>
> --
> Alan G
> Author of the Learn to Program web site
> http://www.alan-g.me.uk/
> http://www.amazon.com/author/alan_gauld
> Follow my photo-blog on Flickr at:
> http://www.flickr.com/photos/alangauldphotos
>
>
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>


More information about the Tutor mailing list