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

1

u/TheSkiGeek Dec 09 '25

Have you actually seen a production system that is storing UNIX-style timestamps in a floating point number? That seems like a terrible idea on so many levels.

Typically either you’re going to use a signed 64-bit integer (not in the C89 spec but a common compiler extension), or define a struct that holds two 32-bit integers and functions to work with them.

Or you’re going to use a platform specific type that works with the platform’s API for dates and times. (Which, again, I’ve never seen one that is ‘natively’ floating point, but maybe it exists somewhere.) If you’re on a POSIX platform and it has 64-bit clocks typically time_t will be some kind of 64-bit integer as well.

1

u/flatfinger Dec 09 '25

How about Javascript, which uses a double-precision floating-point value that represents the number of milliseconds since the Unix epoch?

1

u/TheSkiGeek Dec 09 '25 edited Dec 09 '25

I’m gonna say that “only supporting FP values for literally everything” is also a terrible idea on so many levels. But some high level languages do that, yes.

Edit: also worth noting that JS Date objects are conceptually storing an integer timestamp. A JS interpreter could theoretically store those objects as integers and convert to and from doubles as required.

Edit: V8 defines it as its own data type distinct from ‘regular’ numbers: https://v8docs.nodesource.com/node-0.8/dc/d0a/classv8_1_1_value.html , but I’d have to dig through the source code to see what the underlying stored type is.

1

u/flatfinger Dec 09 '25

Prior to Javascript, VB6 (Visual BASIC 6) used double-precision floating-point values for dates/times as well. If I recall, each unit represented 86,400 seconds. This could accommodate sub-second accuracy even though there was no integer data type bigger than a 32-bit signed integer. Like it or not, a lot of production code was written in that.

1

u/TheSkiGeek Dec 09 '25

Yet another reason I’m glad to have avoided ever working in VB.

1

u/flatfinger Dec 09 '25

On a list of things not to like about VB6, I don't think the use of floating-point values for date/timestamps would even make the top 100.

1

u/Langdon_St_Ives Dec 09 '25

So the second example to cite for languages that use floats to store time is the only language with a worse design than JS. Way to go.

1

u/flatfinger Dec 09 '25

In a language which lacks 64-bit integer types, use of a double-precision float for values that would be too big for 32-bit integers but will fit in 51 bits makes a lot of sense. People take long integer types for granted these days, but they weren't always available. Using a single number to represent a time stamp is a lot more convenient than having to work with separate upper and lower portions.

1

u/Langdon_St_Ives Dec 09 '25

A lack of robust integer types is a major design flaw whichever way you look at it.

1

u/flatfinger Dec 10 '25

Double-precision floating-point format can precisely represent all values of a 32-bit integer, and Javascript bitwise operators work just as they would on 32-bit integers. Javascript does support array-of-integer types, and for most tasks the performance downsides of using floating-point are small enough not to matter.

Unless a language is going to support separate integer- and floating-point division operators, having only one kind of non-array number is a cleaner design than having multiple types.

1

u/andrew-mcg Dec 11 '25

Sinclair Basic had a 40-bit floating-point representation that stored 17-bit signed integers as such internally, and a 39-bit float for everything else.

No native support for dates and times though.