Difference between revisions of "3228: Day Counter"

Explain xkcd: It's 'cause you're dumb.
Jump to: navigation, search
(Page is less than 2.99999999 days old and still under regular revision. Most additions were redundant to existing text. Can't see if the sign is attached by nails or by something else.)
m (Mark claim that original version of this comic contained -0.0[...]017 not -0.0[...]044 with Template:actual citation needed)
Line 39: Line 39:
 
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). 2,147,483,647 days from the comic's date of publication (April 3<sup>rd</sup>, 2026) is approximately October 12<sup>th</sup> of the year 5,881,636, assuming no changes in the lengths of the day and year, or in other aspects of time measurement.
 
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). 2,147,483,647 days from the comic's date of publication (April 3<sup>rd</sup>, 2026) is approximately October 12<sup>th</sup> 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, probably so that it would be more realistic, −0.00000000000000017 would correspond to the very last bit of mantissa being incorrect and only for numbers between 1 and 2 (not including 2), and operation (1-1) is unlikely to result in rounding errors, so the smallest difference from integer is usually higher, which would result in −0.00000000000000044 the smallest possible  rounding error for values between 2 and 4.
+
Strangely enough, when the comic was first published the sign number was −0.00000000000000017 days.{{actual citation needed}} It was changed later though, probably so that it would be more realistic, −0.00000000000000017 would correspond to the very last bit of mantissa being incorrect and only for numbers between 1 and 2 (not including 2), and operation (1-1) is unlikely to result in rounding errors, so the smallest difference from integer is usually higher, which would result in −0.00000000000000044 the smallest possible  rounding error for values between 2 and 4.
  
 
Integer overflow was the topic of [[571: Can't Sleep]], with yet another example of a 'days since' sign being [[3140: Biology Department]] (two examples, in both the comic and its title text).
 
Integer overflow was the topic of [[571: Can't Sleep]], with yet another example of a 'days since' sign being [[3140: Biology Department]] (two examples, in both the comic and its title text).

Revision as of 22:42, 6 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 61 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. (However, it may also lead workers to cover up or conceal accidents, for the same reason, which would tend to increase future accidents, because they do not report the need to correct hazardous conditions that are causing accidents.)

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 3s repeat forever. When a number is truncated to fit in the finite amount of space, precision is inevitably lost, resulting in a slight rounding error. Unless carefully controlled, these rounding 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, which might not trigger the code to do what it should do when three thirds have been accumulated (it can be mitigated by allowing a match for a value which is within a suitably very small difference to the test value, but this must be considered carefully to not be over-/under-sensitive). 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 as the units and 1 after the radix (ternary) point). 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 guaranteed 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.30000000000000004.

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 value −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, and is at least self-consistent, like with 363: Reset)

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 were 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 maintains its own "error state" in a self-referential way. Also, if they tried to reset the sign, they might make the same error again, repeating the cycle over and 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.[actual citation needed] It was changed later though, probably so that it would be more realistic, −0.00000000000000017 would correspond to the very last bit of mantissa being incorrect and only for numbers between 1 and 2 (not including 2), and operation (1-1) is unlikely to result in rounding errors, so the smallest difference from integer is usually higher, which would result in −0.00000000000000044 the smallest possible rounding error for values between 2 and 4.

Integer overflow was the topic of 571: Can't Sleep, with yet another example of a 'days since' sign being 3140: Biology Department (two examples, in both the comic and its title text).

It should be noted that computers displaying things like "-1 seconds until the next [blank]" is a glitch that actually happens.

Transcript

[White Hat, Ponytail, Cueball, and Megan are all below a large sign, which appears to be attached to the wall at its four corners. 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)

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 simple example that could generate −0.00000000000000017. (Which is not to say there isn't one.) —Scs (talk) 15:15, 3 April 2026 (UTC), edited 15:39, 4 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)

I don't think it's significant that Cueball appears to be floating. Randall sometimes draws people in chairs that way. See, for example, 2949, 3015, and 3052. —Scs (talk) 23:25, 5 April 2026 (UTC)
Some of the examples are also seen in What If? and What If? 2. (Yup) Cream Starlight (talk) 04:42, 6 April 2026 (UTC)

My guess is that irrational numbers have "infinite digits" in any base, but my math education is not good enough even to know how to start to prove it, an informal confirmation would be appreciated. 5.91.22.162 22:14, 3 April 2026 (UTC)

As a decimal in a certain base is just a fraction (with a denominator of a power of the base), numbers with finite decimal expansions must be rational (assuming the base is rational) Logalex8369 (talk) 23:31, 3 April 2026 (UTC)
Let's all work in base π so we can have irrational discussions that make sense. What's e in base π?98.22.184.160 12:49, 4 April 2026 (UTC)
I want to meditate on all the transcendental numbers. 81.179.199.253 19:32, 4 April 2026 (UTC)

Plot twist: This is accurate, just too precise and able to predict the future. Someone is about to cause one. 47.141.37.161 05:24, 4 April 2026 (UTC)

Doesn't have to be predicting the future to be accurate. Maybe it means that the last error occurred 38 picoseconds ago. Gorcq (talk) 14:26, 4 April 2026 (UTC)

Surprised that there hasn't been an Artemis II comic yet. --Funstuff4fun (talk) 06:12, 4 April 2026 (UTC)

Sorry, new to posting; sorry if I am misunderstanding. The text describes −0.00000000000000044 as a very small negative number. Is this saying that it is close to zero? If so, would that be better expressed as large, rather than small? Flickerwit (talk) 15:54, 4 April 2026 (UTC)

The value is very small. The representation of the number is large (or fairly large, by some certain limited measure). But you wouldn't call 0.9 "smaller", or 'closer to zero'/"0", than "0.8888888888..." under most usages. Even though that might be correct in a string-handling context. 81.179.199.253 19:32, 4 April 2026 (UTC)
"Greater" and "lesser" work like that (with -1 being greater than -2), but "larger" and "smaller" are more ambiguous, and often refer to the absolute value. 192.112.253.21 02:58, 6 April 2026 (UTC)
One generally would not describe −0.00000000000000044 as "large" (rather than "larger", in direct comparison), except maybe in the implicit context of numbers that routinely are orders of magnitude less (in absolute terms) or are consistently more negative (e.g. zero is an upper limit and one or other of -0.5, -5 or -5,000,000 could be more typical value).
In the context of natural numbers, it is "small" in the grand scheme of things (or 'extremely middling', on a signum-observing basis, given how close to zero it is), especially given the implied floating precision which might suggest that 44,000,000,000,000,000 (or something not too disimilar to it — same significand, as above, but the most positive version of the base-exponent, not the nost negative) is another possible stored value that can be represented. 82.132.239.70 12:58, 6 April 2026 (UTC)

Considering how close to April Fools this comic is, it could be a remnant of such a prank that they haven't bothered to clean up yet. 2001:1C02:1A9D:9700:A420:F4F:966C:167E 16:32, 4 April 2026 (UTC)

If anyone's wondering, it appears that they made it roughly 5,879 millennia, six centuries, and one decade without an integer overflow error. DL Draco Rex (talk) 19:34, 5 April 2026 (UTC)

...I rather think it means that it will be that long until they aren't having one. ;) 81.179.199.253 21:08, 5 April 2026 (UTC)

I agree with DL Draco Rex: they started a 32 bit signed integer counter on -5877585-09-23 of the proleptic Gregorian calendar, so that the counter goes

days since our last integer overflow.
counter date
0 -5877585-09-23
1 -5877585-09-24
2 -5877585-09-25
... ...
2146743572 -001-12-30
2146743573 -001-12-31
2146743574 0000-01-01
2146743575 0000-01-02
... ...
2147483646 2026-04-01
2147483647 2026-04-02
-2147483648 2026-04-03

Qprz (talk) 12:59, 6 April 2026 (UTC)

...I think year 0 technically does not exist?? Cream Starlight (talk) 10:34, 7 April 2026 (UTC)
Year 0 exists in [Astronomical Year Numbering]. Astronomer count years -1, 0, 1, 2 while historian 2BC, 1BC, 1CE, 2CE (BC is Before Christ, CE is Common Era). Qprz (talk) 20:35, 7 April 2026 (UTC)


<Skeletor Voice>Remember! When a company celebrates 365 days since an incident, they are celebrating the anniversary of said incident. ...Until we meet again!</Skeletor Voice> 57.140.28.54 13:57, 6 April 2026 (UTC)

BTW there is an off-by-one error in the sentence

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.

According to numpy datetime64 we have

>>> np.datetime64('2026-04-03', 'D') + 2147483647
np.datetime64('5881636-10-11')

so I would rather say "2,147,483,647 days from the comic's date of publication (April 3rd, 2026) is October 11th of the year 5,881,636 of the Gregorian calendar".

The computation above is exact with respect of the Gregorian calendar rules, not approximate. Concerns about changes in the length of day (LOD) due to [tidal braking] are not relevant here, since the Gregorian Calendar counts days, irrespective of their measured length in SI seconds. What matters is the discrepancy between the mean Gregorian year with respect to mean tropical year, which is also slowly changing. This discrepancy will require a calendar reform if the vernal equinox is to be kept close to the current date (March 21), in about 1200 years, see [Calendar Year]. But the Gregorian Calendar is strictly algoritmical, not observational, so its extrapolation in a distant future is legitimate. Qprz (talk) 14:20, 6 April 2026 (UTC)

What is the source of the claim that the original version of the comic has -0.0[...]017? If anyone has a copy of that version, it belongs in a "Trivia" section. Until then, extraordinary claims require extraordinary evidence... Eunakria (talk) 22:39, 6 April 2026 (UTC)
      comment.png  Add comment