Difference between revisions of "3228: Day Counter"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Explanation: Added a bit about programming and title text, I guess dropdown menu is explained in the previous comic, leaving for now)
(Transcript: cats)
(15 intermediate revisions by 6 users not shown)
Line 10: Line 10:
  
 
==Explanation==
 
==Explanation==
 +
 
{{incomplete|This page was created -.000000000000000032 days ago. Don't remove this notice too soon.}}
 
{{incomplete|This page was created -.000000000000000032 days ago. Don't remove this notice too soon.}}
{{w|Floating points}} are numbers written in {{w|Scientific Notation}}, rounded to fit. They are often used for very large/small numbers, where writing the full number would get incredibly long. However, the rounding required to make these numbers can result in quite big rounding errors, which can cause a fair amount of trouble.
 
  
This is shown in the comic, where a counter is shown of days since there was last a floating point error. However, the amount of time has been changed from a floating point & back, creating 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 less than a microsecond 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.
+
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.
  
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 it's numerous settings.
+
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 {{w|Floating-point arithmetic|floating point number}} or other fraction.  However, many {{w|real numbers}} and {{w|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.
  
Floating point errors are particularly common in programming, specially 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 "warps around" to the smallest value. In case of 32-bit signed integers this value is -2^-31, that is −2,147,483,648.
+
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 <tt>0.000110011001100110011</tt>…A classic example is that, depending on circumstances, the calculation 0.1 + 0.2 might [https://stackoverflow.com/questions/588004/is-floating-point-math-broken seem to give an answer of 0.30000001].
  
The dropdown menu beneath the comic allows the user to select different "modes".  These include the typical "Light mode" and "Dark mode", but also includes some atypical modes such as "Dorian Greyscale Mode" which gradually turns the page darker shades of grey to simulate aging as in the 1890 Oscar Wilde story "The Picture of Dorian Gray".
+
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 {{w|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 {{w|C (programming language)|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{{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 — 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 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 −0.00000000000000017 days. It was changed later though, for unknown reasons.
  
 
==Transcript==
 
==Transcript==
[A sign is on a wall, reading: 'It has been -0.00000000000000044 days since our last floating point error', with the number in it's own box. Below, Ponytail (with her hand raised) & White Hat are talking, Cueball is working at a computer on a desk, while somehow levitating off his chair, & Megan is walking away.]
+
[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
  
 
{{comic discussion}}<noinclude>[[Category:Interactive comics]][[Category:Dynamic comics]]
 
{{comic discussion}}<noinclude>[[Category:Interactive comics]][[Category:Dynamic comics]]
 +
[[Category:Programming]]
 +
[[Category:Math]]
 +
[[Category:Comics featuring White Hat]]
 +
[[Category:Comics featuring Ponytail]]
 +
[[Category:Comics featuring Cueball]]
 +
[[Category:Comics featuring Megan]]

Revision as of 17:13, 3 April 2026

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

Ambox warning blue construction.png 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.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).

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

comment.png  Add comment      new topic.png  Create topic (use sparingly)     refresh discuss.png  Refresh 

Discussion

Someone has to be first 2401:D005:D402:7A00:780:9D40:A38A:98A0 13:14, 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)
      comment.png  Add comment