Year 2038 problem

Today, let’s talk about from the future. 2038 is the year that interests all of the computer systems which is using Unix’s time system epoch (also called timestamp) in the 32-bit integer format. Until this year, lots of system that not updated in hardware or software, will have become unusable or face with many problems.

Well, what is the year 2038 problem? This is a problem that impact mostly 32-bit computer systems which is using Unix time format. To sum up the epoch, a numeric counter starting from 1 January 1970 00:00:00 which is 0, and incrementing every second. If epoch is 1 the date will be 1 January 1970 00:00:01, for 124 it will be 00:02:04. An integer in the 32-bit computer system, the value can be maximum 2147483647. If an Unix time system (I will call it as just epoch now on) stored in 32-bit integer, date will show 19 January 2038, 03:14:07. Okay, what will happen then? If the maximum value incremented with 1, the value will have become -2147483647 which is minus of 2147483647 is equals to 13 December 1901, 03:14:07. So the problem arises from here.

Well, why an 32-bit integer value become minus number after the maximum value has exceeded? We can test it with an simple C program:

int main()
    printf("Value: %d", 2147483647 + 1); // Value: -2147483648
    return 0;

The reason of the result above is, binary equivalent of the integer value 2147483647 is 01111111 11111111 11111111 11111111. The first bit of a signed integer indicates is negative or pozitive. 0 means pozitive, 1 means negantive on the binary. If we incremented it with 1, the binary equivalent will have become 10000000 00000000 00000000 00000000 and it is equals to -2147483648.

For the unsigned integers, the maximum value is 4294967295 and its equivalent of the date is 7 February 2106. Usually integer variables using in signed, this is why it’s called year 2038 problem.

What will have impact by the year 2038 problem? After 2038, a lot of system that storing integer values in 32-bit, including video games, commercial and banking softwares, embedded devices will may have critical problems.

The most possible solution is very simple; keeping epoch values in 64-bit integer. Maximum value a 64-bit integer can take 9223372036854775807. The approximate date is 4 December 292277026596. Until this date, I don’t think that life can continue on the earth, or 64-bit processors still using there :) When time is come, someone will talk about the 292277026596 problem. Currently, we don’t have to worry about it.