# Why is 2,147,483,647 the max int value?

14 views
Is 2147483647 max number? What is int32 MaxValue?  What is the 64 bit integer limit?

What is the highest number a computer can count to?

reshown

2,147,483,647 max int: This is not a random number. This is 2 to the power 31 minus 1 which is a prime number discovered by Leonhard Euler back in 1772. At that time it was the largest prime number ever discovered.

But why is 2,147,483,647 a special number?

Problems 2,147,483,647 will cause:

And what problems was it about to cause in today's world?

2,147,483,647 is the maximum positive value for a 32-bit signed binary integer in computing. That was too much information in a tiny sentence, so let’s illustrate:

32-bit computers store data in a sequence of 32 binary numbers. That's 32 numbers where each number could be either 0 or 1. A signed number means that it could be either positive or negative, thus they are preceded with a sign.

2,147,483,647 representation:

So here's how you represent the number 0 in 32-bits. And here's how you represent +2,147,483,647.The first 0 means that this is a positive number. So this is the maximum signed number that you can represent in a 32-bit computer. On those 32-bit computers a signed number can go from -2,147,483,648 to +2,147,483,647.

Now 2,147,483,647 seems like a huge number, it's well over 2 billion.But why is it a problem?

Is it because some crazy rich guy cannot represent how much money he's got using a 32-bit integer?

No!

The problem is that computers represent the current date and time by counting the number of seconds since January 1, 1970 UTC.

And that number used to be stored in a 32-bit signed number. We call the number of seconds since 1970 the UNIX Timestamp. At the time of recording, the current timestamp is 1,507,568,245 which is shown in binary here.

Now let's fast forward to Tuesday January 19, 2038 03:14:07 UTC.

At this precise second, the number that stores the time will reach its maximum value of 2,147,483,647.

Consequences due to 2,147,483,647:

What do you think will happen when the number is maxed out?

Are servers going to be damaged?

Of course not!

It's simply going to reset.

We will go from +2,147,483,647 to -2,147,483,648 which will take us back to December 13, 1901.

Not literally, that would be awesome though!

Only the time calculated will be wrong and that would cause a lot of issues with payments,

smart cities and pretty much anything that's running on a computer.

This is what's known as the year 2038 problem.

Thankfully this is not a problem anymore as most computers have moved or will have move

to 64-bit by the time it's 2038.

But wait, wouldn't 64-bit just delay the problem a few more years?

Well on 64-bit computers the maximum value for a signed number is by far greater than

2,147,483,647.

To be precise it is nine quintillion two hundred twenty-three quadrillion three hundred seventy-two

trillion thirty-six billion eight hundred fifty-four million seven hundred seventy-five

thousand eight hundred and seven.

This will allow us to expand the time representable by approximately 293 billion years, which

is way after the sun would have become a supernova and destroyed the earth.

That's reassuring!

So using 64-bit computers solves the year 2038 problem.

I just hope we won't have any 32-bit computers still hanging by then.

That's very likely since most of the ATMs at the moment are still running Windows XP.

by (8.9k points)