Difference between revisions of "3228: Day Counter"
(→Explanation) |
(→Explanation: rm explicit parentheses that I added unnecessarily. also change some - to −) |
||
| Line 33: | Line 33: | ||
The program starts with the number 19, and subtracts 1.9 from it, ten times. Mathematically, we would expect the result to be 0. However, the number 1.9 cannot be represented exactly in binary, nor can the intermediate results 17.1, 15.2, 13.3, etc. The cascading roundoff errors conspire to produce a result of −0.00000000000000044 instead of the expected 0. | The program starts with the number 19, and subtracts 1.9 from it, ten times. Mathematically, we would expect the result to be 0. However, the number 1.9 cannot be represented exactly in binary, nor can the intermediate results 17.1, 15.2, 13.3, etc. The cascading roundoff errors conspire to produce a result of −0.00000000000000044 instead of the expected 0. | ||
| − | In the comic, such an error creates the ridiculous illusion that | + | In the comic, such an error creates the ridiculous illusion that −0.00000000000000044 days have passed, which implies a 'negative' number of days, which is impossible{{cn}}. It also, even if it was a positive number, would mean that much less than a nanosecond had passed since the last error, which would be an unfeasably short amount of time. Of course, the joke is that in making the sign showing the amount of time since a floating point error was last made, they are creating a floating point error, meaning the sign is invalid. Also, if they tried to reset the sign, they might make the same error again, repeating the cycle over & over, which would not be ideal. |
| − | Coincidentally enough, [[Cueball]] is also floating | + | Coincidentally enough, [[Cueball]] is also floating — off his seat in this case. The seat itself looks the same as the chair in [[2144]], possibly meaning making people levitate is one of its numerous settings. |
| − | Floating point errors are particularly common in programming, especially in languages that implicitly convert decimal numbers to binary floating point, so an approximation is already made at conversion leading to unexpected results. The title text cites another common programming problem, integer overflow. When a value gets bigger than the biggest integer that can be represented in a certain format, it "wraps around" to the smallest value. In case of 32-bit signed integers it may wrap from 2<sup>31</sup> | + | Floating point errors are particularly common in programming, especially in languages that implicitly convert decimal numbers to binary floating point, so an approximation is already made at conversion leading to unexpected results. The title text cites another common programming problem, integer overflow. When a value gets bigger than the biggest integer that can be represented in a certain format, it typically "wraps around" to the smallest value. In case of 32-bit signed integers it may wrap from 2<sup>31</sup>−1 (2,147,483,647) to −2<sup>31</sup> (−2,147,483,648). |
| − | Strangely enough, when the comic was first published the sign number was | + | Strangely enough, when the comic was first published the sign number was −0.00000000000000017 days. |
==Transcript== | ==Transcript== | ||
Revision as of 15:36, 3 April 2026
| Day Counter |
Title text: It has been −2,147,483,648 days since our last integer overflow. |
Explanation
| This is one of 65 incomplete explanations: This page was created -.000000000000000032 days ago. Don't remove this notice too soon. If you can fix this issue, edit the page! |
A common feature of an industrial setting is a prominent sign announcing how many days have elapsed since the last workplace accident. The sign is typically updated each day to a number one higher — or back to zero, if there has been an accident. Such signs are intended to foster a culture of safety among the workers in the facility, since presumably no one wants to suffer the embarrassment of being the one to have caused an accident that resets the number to 0.
In this comic, a similar sign highlights the number of days since the last floating-point error. Floating-point errors occur because most computers can devote only a finite amount of storage for each floating point number or other fraction. However, many real numbers and rational numbers theoretically require an infinite number of digits to represent them. For example, the ordinary fraction ⅓ is represented in decimal as 0.3333333333…, where the 3's repeat forever. When a number is truncated to fit in the finite amount of space, precision is inevitably lost, resulting in a slight roundoff error. Unless carefully controlled, these roundoff errors can accumulate, significantly degrading the accuracy of floating-point computations. For example, although ⅓ + ⅓ + ⅓ should obviously equal 1, a finite-precision calculation like 0.333 + 0.333 + 0.333 might show a misleading result of 0.999.
This issue is exacerbated on computers which use binary arithmetic (i.e., virtually all computers today), since in binary, the ordinary fraction 1/10 is represented as the infinitely-repeating base-2 fraction 0.00011001100110011011…. A classic example is that, depending on circumstances, the calculation 0.1 + 0.2 might seem to give an answer of 0.30000001.
Evidently, in the programming facility shown in the comic, a floating-point error has occurred today, and an attempt has been made to update the sign to say "It has been 0 days since...". But the number 0 is displayed incorrectly, as the very small negative number −0.00000000000000044. Perhaps the error that was made today was the very error that occurred in updating the sign! (This would of course violate causality, but in comedy, self-referential humor beats causality every time.)
As an example of how the number −0.00000000000000044 could have arisen when 0 was intended, consider this simple C program:
#include <stdio.h>
int main()
{
double d = 19;
for(int i = 0; i < 10; i++) d -= 1.9;
printf("%.17f\n", d);
}
The program starts with the number 19, and subtracts 1.9 from it, ten times. Mathematically, we would expect the result to be 0. However, the number 1.9 cannot be represented exactly in binary, nor can the intermediate results 17.1, 15.2, 13.3, etc. The cascading roundoff errors conspire to produce a result of −0.00000000000000044 instead of the expected 0.
In the comic, such an error creates the ridiculous illusion that −0.00000000000000044 days have passed, which implies a 'negative' number of days, which is impossible[citation needed]. It also, even if it was a positive number, would mean that much less than a nanosecond had passed since the last error, which would be an unfeasably short amount of time. Of course, the joke is that in making the sign showing the amount of time since a floating point error was last made, they are creating a floating point error, meaning the sign is invalid. Also, if they tried to reset the sign, they might make the same error again, repeating the cycle over & over, which would not be ideal.
Coincidentally enough, Cueball is also floating — off his seat in this case. The seat itself looks the same as the chair in 2144, possibly meaning making people levitate is one of its numerous settings.
Floating point errors are particularly common in programming, especially in languages that implicitly convert decimal numbers to binary floating point, so an approximation is already made at conversion leading to unexpected results. The title text cites another common programming problem, integer overflow. When a value gets bigger than the biggest integer that can be represented in a certain format, it typically "wraps around" to the smallest value. In case of 32-bit signed integers it may wrap from 231−1 (2,147,483,647) to −231 (−2,147,483,648).
Strangely enough, when the comic was first published the sign number was −0.00000000000000017 days.
Transcript
[White Hat, Ponytail, Cueball, and Megan are all below a large sign. White Hat and Ponytail appear to be discussing something, while Cueball is sitting at his desk working on a laptop and Megan is walking away. The sign has text on it, as well as a large display presumably meant to show a number.]
- [Sign:] It has been
- [Display:] -0.00000000000000044
- [Sign:] days since our last floating point error
Discussion
Someone has to be first 2401:D005:D402:7A00:780:9D40:A38A:98A0 13:14, 3 April 2026 (UTC)
- No, but someone has to be the 0.99999999999999956th... 81.179.199.253 21:58, 3 April 2026 (UTC)
In response to the comment added by @GSLikesCats307, "When the comic was first published the number was −0.00000000000000017 days": Perhaps Randall was just trying to make things a bit more realistic. I've shown a realistic example that could generate −0.00000000000000044. My experiments didn't find any examples that could generate −0.00000000000000017. —Scs (talk) 15:15, 3 April 2026 (UTC)
The day counter is now showing −0.00000000000000044 on my Windows 11 system using Chrome. Maybe the result differs based on computer/browser combination? 72.218.191.213 16:16, 3 April 2026 (UTC)
The April Fools dark mode thing was kept! Lets go! King Pando (talk) 16:25, 3 April 2026 (UTC)
This comic was published during NASA's Artemis II moon mission. Could Cueball seeming to be floating above his chair be a reference to null gravity? PDesbeginner (talk) 17:12, 3 April 2026 (UTC)