UNIX rollover - why 2^31 signed and not 2^32 unsigned? - Page 1
Forum section: electronics / general

author: Circlotron
author_rank: Super Contributor
timestamp: May 04, 2022, 11:55:47 pm
content: We all know that if nothing is done, UNIX will conk out early 2038 because there are 2^31 seconds from 1 January 1970 till 19th January 2038. My question is - why was a signed integer that has a maximum positive value of 2^31 used as the seconds counter when an unsigned integer value of 2^32 could have been chosen? That would give a counter twice as long. The only reason I can think of is, being signed, it could also deal with negative numbers, that is, dates earlier than 1 January 1970. Does that make any sense at all? Is that how it works?https://en.wikipedia.org/wiki/Year_2038_problem

author: Someone
author_rank: Super Contributor
timestamp: May 05, 2022, 12:06:25 am
content: History:https://en.wikipedia.org/wiki/Unix_time#Representing_the_number

author: BrianHG
author_rank: Super Contributor
timestamp: May 05, 2022, 01:09:51 am
content: I just feel it's sad that those who wanted to create an ultimate OS for everyone would settle on a time format which couldn't even make it to 2050, let alone 2100. Maybe this short-sight means unix should be dumped?

author: langwadt
author_rank: Super Contributor
timestamp: May 05, 2022, 01:17:13 am
content: Quote from: BrianHG on May 05, 2022, 01:09:51 amisn't most platforms and timestamps 64bit already?

author: BrianHG
author_rank: Super Contributor
timestamp: May 05, 2022, 01:32:37 am
content: Quote from: langwadt on May 05, 2022, 01:17:13 amIt's not that, it's that they begun with only 31bits of time expecting that they would burn, fail and be completely forgotten by 2038.

author: Monkeh
author_rank: Super Contributor
timestamp: May 05, 2022, 01:53:59 am
content: Quote from: BrianHG on May 05, 2022, 01:09:51 amYou seem to have a very warped idea of how Unix came to be.

author: timenutgoblin
author_rank: Regular Contributor
timestamp: May 05, 2022, 01:54:27 am
content: Quote from: Circlotron on May 04, 2022, 11:55:47 pmYep, we're all doomed and there is nothing we can do to stop it.link to the video here:https://youtu.be/l4UFQWKjy_I

author: ejeffrey
author_rank: Super Contributor
timestamp: May 05, 2022, 05:34:22 am
content: Quote from: Circlotron on May 04, 2022, 11:55:47 pmYes. While UNIX timestamps themselves are rarely negative, it's common to subtract two timestamps to compute the delta between them. If you do that with unsigned types in C the result will be unsigned and wrap to a large positive value for negative deltas.C was also built around the idea of having the basic integer types be of an unspecified width that could be changed to fit the machine in question. To the extent anyone in the 70s worried about Y2.038k, they probably just assumed that changing the type would be no problem. The expectations of binary compatibility and stronger portability were a lot less then than now.

author: daqq
author_rank: Super Contributor
timestamp: May 05, 2022, 06:42:37 am
content: Like most bad things: It seemed good at the time.

author: JohanH
author_rank: Frequent Contributor
timestamp: May 05, 2022, 06:54:46 am
content: Quote from: langwadt on May 05, 2022, 01:17:13 amIn *BSD and Linux most things are fixed. And what is not fixed is planned for.But there are a lot of old software running out there. I've even seen old SCADA type of software on Windows that rely on 32-bit timestamp for some functions. I verified by changing computer date and time and a certain function stopped working in 2038. Nothing critical in this example, though.There was some joking why Germans wanted to stop their nuclear power plants before 2038...

author: Bassman59
author_rank: Super Contributor
timestamp: May 05, 2022, 03:44:49 pm
content: Quote from: ejeffrey on May 05, 2022, 05:34:22 amThank you for writingY2.038kinstead of the more common and completely incorrectY2K38.

author: nightfire
author_rank: Frequent Contributor
timestamp: May 05, 2022, 09:28:54 pm
content: No- back then, Memory and resources were scarce, and by that time the decision was made, the designers were full aware that it would have some limitations- but by year 2038 there would be more powerful systems available, so it was expected that by then a solution/updated version would be available.

author: SiliconWizard
author_rank: Super Contributor
timestamp: May 05, 2022, 09:48:39 pm
content: Quote from: nightfire on May 05, 2022, 09:28:54 pmYeah, sounds reasonable. And actually, the updates have been there for quite a while already.Those still running old software for whatever reason, even if the reason is a good one, are responsible. Not the authors of 50 years ago. Come on. =)

author: PlainName
author_rank: Super Contributor
timestamp: May 08, 2022, 09:05:04 pm
content: Quote from: Bassman59 on May 05, 2022, 03:44:49 pmFor an EE, why would the second not be correct? In fact, wouldn't Y2038 be the actual correct way - Y2K was, after all, just an abbreviation that appealed to computer types and could be mistaken for meaning Y2024.

author: langwadt
author_rank: Super Contributor
timestamp: May 08, 2022, 10:24:40 pm
content: Quote from: dunkemhigh on May 08, 2022, 09:05:04 pmY2K38 would 2380, so if anything it should be Y2K038

author: PlainName
author_rank: Super Contributor
timestamp: May 08, 2022, 11:49:25 pm
content: QuoteAh, good point

author: Nominal Animal
author_rank: Super Contributor
timestamp: May 09, 2022, 02:39:07 pm
content: Quote from: dunkemhigh on May 08, 2022, 09:05:04 pmNot 2024, 211=2048.

author: PlainName
author_rank: Super Contributor
timestamp: May 09, 2022, 03:04:37 pm
content: QuoteJust checking if you're awake

author: eugene
author_rank: Frequent Contributor
timestamp: May 10, 2022, 06:10:07 pm
content: We have 14 years to convert to 256 bit time stamps. That should work until our sun burns out or goes supernova or whatever. If you move to another solar system then you're on your own.

author: hans
author_rank: Super Contributor
timestamp: May 10, 2022, 08:54:26 pm
content: Quote from: BrianHG on May 05, 2022, 01:32:37 amAnd so did Microsoft never thought they would stay around long enough to reach Windows 9Isn't any technology going to have limitations that were unforeseen or planned to be part of future drafts? I mean C is a wonderfully simple language.. but you wouldn't want to program absolutely everything in it neither.