Main Page

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search

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!

 Go to this explanation

Latest comic

Day Counter
It has been −2,147,483,648 days since our last integer overflow.
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, 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. The amount of required space for rational numbers is not universal, it depends on the base used (⅓ in base 3 requires just two digits: 0.1). Floating point arithmetic standards, like the popular IEEE 754, define how and when an approximation should take place, leading to predictable results, but they don't respect some basic properties of common arithmetic operations, which someone may take for granted, e.g. in floating point arithmetic addition and multiplication are commutative (a+b=b+a; a*b=b*a), but aren't guarantied to be associative ((a+b)+c≈a+(b+c)); (a*b)*c≈a*(b*c)).

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.000110011001100110011…. 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). 2,147,483,647 days from the comic's date of publication (April 3rd, 2026) is approximately October 12th of the year 5,881,636, assuming no changes in the lengths of the day and year, or in other aspects of time measurement.

Strangely enough, when the comic was first published the sign number was −0.00000000000000017 days. It was changed later though, for unknown reasons.

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 topic.png  View comic discussion

New here?

Last 7 days (Top 10)

Lots of people contribute to make this wiki a success. Many of the recent contributors above have just joined. You can do it too! Create your account here.

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.

  • 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.