Tuesday, 20 October 2015

A brief history of electronics time

The time_t is a C function which represents time as an integer. This function measures time from 1st January 1970 also known as the 'Unix Time' or 'Epoch Time'. I learnt about this when I was trying to display the date on an LCD using my Arduino UNO.

As I read further; I learnt that the time_t function represents the time since Unix Epoch as a 32 bit binary number which has maximum possible combinations of 4294967296 (2^32). 

This is a limited capacity and it will finish. In binary it will look like this,

1111 1111 1111 1111 1111 1111 1111 1111 
(19.January.2038/03:14:07 UTC)

  
When you add one more bit this to represent the next second it becomes this, 

000 0000 0000 0000 0000 0000 0000 0000 
(13.December.1901/20:45:52)

Which is seemingly innocuous, but see that 0 at the beginning of this number-it means that the number is negative ,which means it will represent a date before 1st Jan 1970. This occurred due to a small mathematical problem known as Integer Overflow. 
While I cannot possibly predict the problems that might be caused due to this, one of the only possible solution to this is to switch to 64 bit architectures which will put the limit of time since Unix Epoch to approx (1.84 * 10^19) or approx 292 billion years .

A problem analogous to this was the year 2000 or Y2K problem. This had occurred due the old age practice of representing years by their last two digits, 1989 was represented as 89 and when the year 2000 came 00 came to represent 1900 or in some cases 19100. 

With this wary note, 

Abhijeet Dutt Srivastava  






1 comment:

  1. An interesting problem. I suspect this issue will get more discussed as we get closer to 2038, just as was the case with Y2K.

    Many Indian software companies - Infosys and TCS to name a few made their reputations working on the Y2K problem for companies. Will some businesses make millions doing this for the 2038 problem too?

    ReplyDelete