Main Page
Welcome to the explain xkcd wiki!
We have an explanation for all 3237 xkcd comics, and only 65 (2%) are incomplete. Help us finish them!
Latest comic
| Day Counter |
Title text: It has been −2,147,483,648 days since our last integer overflow. |
Explanation
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, seriously 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 problem 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 binary fraction 0.00011001100110011011…. A classic example of the problem 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.
This 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 "wraps around" to the smallest value. In case of 32-bit signed integers it wraps from 231-1 (2,147,483,647) to -231 (−2,147,483,648).
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
New here?
Last 7 days (Top 10) |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You can read a brief introduction about this wiki at explain xkcd. Feel free to create an account and contribute to the wiki! We need explanations for xkcd comics, characters, What If? articles, and everything in between. If it is referenced in an xkcd comic, it should be here.
- If you're new to wiki editing, see the explain xkcd:Editor FAQ for a specific guidance to this wiki and the more general help on how to edit wiki pages. There's also a handy wikicode cheatsheet.
- Discussion about the wiki itself happens at the Community portal.
- You can browse the comics from the list of all comics or by navigating the category tree at Category:Comics.
- The incomplete explanations are listed here. Feel free to help out by expanding them!
Rules
Don't be a jerk!
There are a lot of comics that don't have set-in-stone explanations; feel free to put multiple interpretations in the wiki page for each comic.
If you want to talk about a specific comic, use its discussion page.
Please only submit material directly related to xkcd and, of course, only submit material that can legally be posted and freely edited. Off-topic or other inappropriate content is subject to removal or modification at admin discretion, and users who repeatedly post such content will be blocked.
If you need assistance from an admin, post a message to the Admin requests board.
