r/AskComputerScience • • Dec 09 '25

32-bit computers hit a time calculation wall in 2038. Will they most likely all be phased out by then?

The wall hits 03:14:07 UTC on Tuesday, January 19, 2038. After this the time calculation will roll back over to either December 13, 1901 or January 1, 1970 depending on the implementation. Does anyone think 32-bit architecture computers will still be in service by 2038?

143 Upvotes

138 comments sorted by

View all comments

Show parent comment

0

u/[deleted] Dec 09 '25

[deleted] — view deleted comment

3

u/xcookiekiller Dec 09 '25

Unix time is signed. The reason is that they started the whole thing roughly in 1970, so considering that 1970 is the "0", they would not be able to express "2 years ago" if they didn't make it signed

1

u/Successful_Box_1007 Dec 10 '25

Can you explain how “signed” allows us to express “2 years ago”? I know what signed and unsigned integers are just learned about those a few months ago but still a bit confused?

1

u/xcookiekiller Dec 10 '25

If 0 = January 1st 1970, then negative numbers are for everything before that point, while positive ones are for everything after that. If it were unsigned, there would be no before.

2

u/ghjm MSCS, CS Pro (20+) Dec 09 '25

The standard signed bumber format, called 2s complement, was designed to have desirable behavior when wrapping around zero (1 minus 2 "naturally" gives -1, without having to encode special logic to handle the sign). The same wrapping at the other end of the scale means that the largest value plus one equals the smallest (most negative) value. A signed 32-bit integer representing seconds gives a positive or negative range of a little over 68 years. The date chosen for zero is Jan 1 1970, so the maximum positive value is in 2038, and when this value is reached it wraps around to the maximum negative value, in 1901. (Some date libraries ignore negative values, in which case it will wrap around to 1970 and either start counting forward or maybe just stay stuck on 1/1/1970 for 68 years, then start counting forward again.)

2

u/flatfinger Dec 09 '25

I wonder why they chose Jan 1, 1970 rather than something like March 1, 1968? Using March 1 as an epoch date means that one can start by dividing the day number by 1461 (computing both quotient and remainder). Another similar but more puzzling choice was the Apple classic Macintosh, which uses unsigned dates, but chose January 1, 1904 as its epoch date.

2

u/ghjm MSCS, CS Pro (20+) Dec 09 '25

By all accounts it was an arbitrary choice by the early Unix team. Can you explain what you mean about dividing by 1461?

2

u/flatfinger Dec 09 '25

Every group of 4 years has 1461 days, at least until 2099.

1

u/Langdon_St_Ives Dec 09 '25

What does this buy the cpu?

2

u/flatfinger Dec 09 '25

If one uses March 1 as the epoch, leap day will be the last day out of each group of 1461 days.

2

u/Langdon_St_Ives Dec 09 '25

Still fail to see what this buys us. It’s already trivial to work out leap days during the limited time range you specify, and only marginally less trivial beyond that.

2

u/flatfinger Dec 09 '25

It's not terribly hard either way, but the code ends up being a little simpler, and January 1 isn't really any less arbitrary than March 1. What's weird is that the new year was changed from March 21 to January 1 rather than March 1 (note that what we now call the ninth through twelfth months are named as the seventh through tenth months).

1

u/Successful_Box_1007 Dec 10 '25

Hmm but if time moves forward and our clocks only need to show forward time, I still don’t grasp why we even need negatives and need 2s complement instead of just unsigned. Sorry if this is relatively easy just curious why?

1

u/ghjm MSCS, CS Pro (20+) Dec 10 '25

Some applications need to refer to dates in the past. Like, suppose you have a date of birth field. (Though you generally wouldn't use a Unix style date for that.)