[Tutor] Hoping for a brief explanation!
avi.e.gross at gmail.com
avi.e.gross at gmail.com
Tue Aug 16 12:21:51 EDT 2022
As several others have said, this is not a bug but a feature. Normal
floating point in just about any language that fits what various standard
bodies have declared, has limits on what it stores. You went over the limit.
But think also of Mathematics where .99999999999999... is asymptotically
approaching 1 as you add more 9's but even though one intuition is that it
can never reach one, the other intuition is that in an infinite limit, it
can get as close to 1 to the point where for all practical purposes it is 1!
So the infinite series of
1/2 +1/4 + 1/8 + ... + 1/1024 + ...
Is similarly an asymptotic representation as for all powers of 2, it becomes
things like 1023/1024 of for a denominator of N it becomes
(N-1)/N
As N approaches infinity, both N and N-1 are basically the same and the
ration not only approaches 1 but IS 1.
As mentioned, there are ways to deal with more precision but most ways
eventually have costs and limits.
-----Original Message-----
From: Tutor <tutor-bounces+avi.e.gross=gmail.com at python.org> On Behalf Of C
S
Sent: Monday, August 15, 2022 8:01 PM
To: Tutor at python.org
Subject: [Tutor] Hoping for a brief explanation!
Thank you!
>>> print(10>9.999999999999999)
True
>>> print(10>9.9999999999999999)
False
Python on windows 3.10 64bit.
Sincerely,
Thanks!
--
Cesar Salas
_______________________________________________
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