420
submitted 1 month ago by xkcdbot@lemmy.world to c/xkcd@lemmy.world

xkcd #3228: Day Counter

Title text:

It has been −2,147,483,648 days since our last integer overflow.

Transcript:

Transcript will show once it’s been added to explainxkcd.com

Source: https://xkcd.com/3228/

explainxkcd for #3228

you are viewing a single comment's thread
view the rest of the comments
[-] Winter_Oven@piefed.social 10 points 1 month ago

why is it a negative number for the floating point error one? Doesn't a day counter either increments or be set to zero? are they minusing the day by the value it holds to make it zero instead of just assigning it zero?? Why??

[-] palordrolap@fedia.io 17 points 1 month ago

At a guess, the counter goes up by fractions of a day internally, but it's reset by subtracting the integer part, rounded.

The original version wouldn't have had the rounding but they "fixed" that after the first time they did a reset and it went to 1 not 0.

As to why they wouldn't just set it to zero, well here we have the joke under a microscope and it's struggling to stay alive. Put the scalpel down.

[-] jdnewmil@lemmy.ca 2 points 1 month ago

... they were just about to experience a floating point error when the sign was put up.

[-] obstbert@feddit.org 1 points 1 month ago* (last edited 1 month ago)

They're using a signed 32-bit integer which can overflow to negative numbers. An unsigned integer would roll over to just 0, but then the joke wouldn't work.

Edit: I misread the question and was thinking about the title text

this post was submitted on 03 Apr 2026
420 points (99.5% liked)

xkcd

16520 readers
78 users here now

A community for a webcomic of romance, sarcasm, math, and language.

founded 3 years ago
MODERATORS