• Register
Welcome to Kodlogs Q&A, where you can ask programming questions and receive answers from other members of the community. For programmers, by programmers Kodlogs is an open community for anyone that does coding. We help you get answers to your toughest coding questions, share knowledge with your coworkers in private, and find your next IT dream job.

Most popular tags

java program php python javascript c# android r c spring-boot arrays html mysql entity-framework sql-server matlab redirect code program numpy spring asp loop net class quirks-mode internet-explorer-9 internet-explorer machine-learning winforms visual-studio-2010 webpack python-3 python-2 aspnet dataframe pandas jdbc ios eclipse sum loops css cmd tcp math security jquery sockets sql 7 number firebase-authentication aws-organizations amazon-web-services php-7 string-formatting cplusplus visual-studio-2015 net-core net-mvc msbuild extension-methods foreign-keys sql-server-2005 windows-services react-redux reactjs inputstream facebook-graph-api for-loop entity-framework-4 reportingservices-2005 reporting-services mips linear-regression scikit-learn anova deep-learning keras block-device melt reshape2 floating-point webpack-dev-server javascrip 0-lollipop android-5 statsmodels avx indentation-error eclipseide javafx-2 php-not-recognized laravel command-line unit-testing tinyurl atom-editor android-emulator android-studio android-sdk-tools ionic2 cordova jupyter-notebook foobar2k tcplistener net-2 net-4 ole-db-provider windows-10 vagrantfile ggplot2 glmnet jvm-arguments global-variables orm virtualenv atom xls oledb redux webclient prediction headless hyperlink outlook pipeline iis perfect-square objective-c carthage xcode8 compiler-errors numpy-ndarray standard-deviation xampp apple mdf destructor vagrant gettime gmail ioexception heuristics milliseconds reporting cpu npm modx-revolution goldsky modx prevnext javascript-dictionary stack-smashing device-monitor radio-button android-actionbaractivity android-activity android-fragments java-long unqualified-id ora-12154 javc c++ java nullpointerexception runtime-error drjava awt-eventqueue dsx math-pow ajquery nosuchelementexception appcompatactivity jtextfield jpanel inputmismatchexception deque jupyter javafx lvalue junit tensorflow ibm factorial servlet apache boot virtualbox indentation jvm margins 2147483647 xcode firebase plot deployment processor automation socketexception pointers concatenation oracle devices color recursion sequence search date caching expected response directory csv algorithms release collections facebook float figure url expression microsoft sorting sort datetime httpwebrequest cryptography json ajax exe dictionary required windows string variable size dll system exception files x int function random import code 2
0 votes
12 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?
by (1.5k points)  
reshown by

1 Answer

0 votes

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)  
...