The -1 is since integers start at 0, but our counting starts in ~ 1.

You are watching: What is the largest unsigned 32-bit binary number

So, 2^32-1 is the *maximum value* because that a 32-bit unsigned integer (32 binary digits). 2^32 is the *number of feasible values*.

To simplify why, look in ~ decimal. 10^2-1 is the maximum worth of a 2-digit decimal number (99). Because our intuitive human counting starts in ~ 1, yet integers room 0-based, 10^2 is the variety of values (100).

2^32 in binary:

1 00000000 00000000 00000000 000000002^32 - 1 in binary:

11111111 11111111 11111111 11111111As you deserve to see, 2^32 take away 33 bits, conversely, 2^32 - 1 is the maximum value of a 32 little integer.

The factor for the seemingly "off-by-one" error below is that the lowest little bit represents a one, not a two. Therefore the ** first** little is actually 2^0, the

**little is 2^1, etc...**

*second*232 in binary is one complied with by 32 zeroes, because that a total of

**33**bits. That doesn"t right in a 32-bit int value.

The numbers from 0 to N space not N. They room N+1. This is not obvious to the majority of people and also as a result many programs have actually bugs because if this reason.

If you"re just starting out v programming, I indicate you take it a look in ~ this wiki post on signed number representations

As Vicente has actually stated, the reason you subtract 1 is because 0 is also an contained number. As a straightforward example, v 3 bits, you deserve to represent the following non-negative integers

0 : 0001 : 0012 : 0103 : 0114 : 1005 : 1016 : 1107 : 111Anything past that requires more than 3 digits. Hence, the max number you deserve to represent is 2^3-1=7. Thus, you can prolong this to any kind of n and say that you can express integers in the selection <0,2^n -1>. Now you have the right to go check out that article and understand the different forms, and also representing negative integers, etc.

It"s due to the fact that in computing, numbers begin at 0. Therefore if you have, for example, 32 attend to lines (232 addressable bytes), they will be in the selection <0, 2^32).

Because 0 is additionally represented. The quantity of numbers you can represent is certainly 2^n with n bits, yet the best number is 2^n-1 due to the fact that you have to start the count in 0, that is, every bit collection to 0.

For 1 bit: 0, 1For 2 bits: 0, 1, 2, 3For 3 bits: 0, 1, 2, 3, 4, 5, 6, 7

And for this reason on.

If ns ask you what is the greatest value you deserve to fit into a 2-digit number, would you to speak it"s 102 (100) or 102-1 (99)? obviously the latter. It adheres to that if i ask you what the greatest n-digit number is, it would certainly be 10n-1. Yet why is there the "-1"? fairly simply, due to the fact that we have the right to represent 0 in a 2-digit number likewise as 00 (but everyone simply writes 0).

Let"s change 10 with an arbitrarily base, b. It adheres to that for a given base, b, the biggest n-digit number you have the right to represent is bn-1. Using a 32-bit (n = 32) base-2 (b = 2) number, we watch that the greatest value we can represent 232-1.

Another means of thinking around it is come use smaller sized numbers. To speak we have actually a 1-bit number. Would certainly you tell me the biggest value it deserve to represent is 21 or 21-1?

Why perform we have the "minus 1"?

Just answer the question: What is *the maximum value of an 1-bit integer*?

**One bit** integer have the right to store just **two** (21) values: 0 and also 1. Last worth is 12 = **1**10

**Two bit** integer can store just **four** (22) values: 00, 01, 10 and also 11. Last value is 112 = **3**10

Thus, as soon as integer can stores N, values last value will be N-1 because counting starts from **zero**.

n little integer have the right to store 2n values. Whereby last will certainly be 2n-1

Example:One byte can store 28 (256) values. Where first is 0 and last is 255

Why isn"t the maximum just 2n?

Because counting starts native zero. Look at first value for any kind of n little integer.For example byte: 00000000

This would be very confusing if:00000001 method 200000000 means 1

would not? ;-)

In many programming languages

*integer is a signed value*(see two"s complement).

For example, in Java and also .NET integer most left byte is booked for sign:

0 => confident or zero number 1 => an unfavorable numberThen the maximum worth for 32-bit number is limited by 2^31. And including -1 we get 2^31 - 1.

Why walk -1 appear?

Look at more simple example with unsigned Byte (8-bits):

1 1 1 1 1 1 1 1128 64 32 16 8 4 2 1 together other males pointed out the most right bit can have a maximum value of 1, not 2, since of 0/1 values.

Int32.MaxValue = 2147483647 (.NET)

Thanks for contributing response to stack Overflow!

Please be sure to*answer the question*. Carry out details and share her research!

But *avoid* …

See more: How Did The Typewriter Change Who Worked In Offices, How Typewriters Changed Everything

To learn more, watch our tips on writing an excellent answers.

short article Your prize Discard

By click “Post her Answer”, girlfriend agree come our regards to service, privacy policy and also cookie policy

## Not the price you're feather for? Browse other questions tagged essence programming-languages numeric-limits or questioning your very own question.

site architecture / logo design © 2021 stack Exchange Inc; user contributions licensed under cc by-sa. Rev2021.10.15.40479

your privacy

By click “Accept all cookies”, friend agree ridge Exchange can store cookie on your maker and disclose information in accordance v our Cookie Policy.