[Tutor] Hoping for a brief explanation!
Alan Gauld
alan.gauld at yahoo.co.uk
Tue Aug 16 08:04:05 EDT 2022
On 16/08/2022 01:01, C S wrote:
> Thank you!
>
>>>> print(10>9.999999999999999)
> True
>>>> print(10>9.9999999999999999)
> False
The brief explanation is that it is due to
floating point rounding errors.
If you don't understand that, you need to read
the full explanation which can be found on Wikipedia
(other resaources are available!)
https://en.wikipedia.org/wiki/Round-off_error
It is slightly baffling when you first come across
it but it bites every programmer at some point and
it is important to know about it and how to deal
with it.
--
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
More information about the Tutor
mailing list