You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: text/main/classes/basics/basics.tex
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -456,11 +456,11 @@
456
456
Usually, that itself is totally fine:
457
457
There are only very few application were we really need more than 15 digits of precision.
458
458
Still, let's continue this example for a bit.
459
-
What happens if we try to compute~$10^{18}+1$ and then subtract~$10^{18}$ from this sum?
459
+
What happens if we try to compute~$10^{16}+1$ and then subtract~$10^{16}$ from this sum?
460
460
Obviously, in an ideal world, the result should be~\pythonil{1.0}.
461
461
While \pythonil{1e16 + 1} would be \pythonil{10_000_000_000_000_001.0} which does not fit in a \pythonil{float}, \pythonil{1.0}~is a number that we can correctly and accurately represent as a~\pythonilIdx{float}.
462
462
The actual result of this computation in \python, however, is~\pythonil{0.0}.
463
-
The reason is that the result of the intermediate computation of \pythonil{1e18 + 1 == 1e18} and then \pythonil{1e18 - 1e18 == 0}.
463
+
The reason is that the result of the intermediate computation of \pythonil{1e16 + 1 == 1e16} and then \pythonil{1e16 - 1e16 == 0}.
464
464
465
465
Similarly, computing \pythonil{1e18 + 1 + 1e36 - 1e36 - 1e18} yields~\pythonil{-1e18}, while the \inQuotes{correct} result would again be~\pythonil{1.0}.
466
466
The reason is that first, \pythonil{1e18 + 1 == 1e18} is computed.
0 commit comments