For instance, if n=9, then exactly how many different values have the right to be represented in 9 binary digits (bits)?

My reasoning is that if I collection each of those 9 bits to 1, I will certainly make the highest possible number feasible that those 9 digits are able to reexisting. Therefore, the greatest value is 1 1111 1111 which amounts to 511 in decimal. I conclude that, therefore, 9 digits of binary deserve to recurrent 511 various worths.

You are watching: In general, how many things can be represented by n bits?

Is my thought procedure correct? If not, could someone kindly define what I"m missing? How can I generalize it to n bits?


binary bits
Share
Improve this question
Follow
edited Nov 1 "12 at 18:03
*

NullUserException
79.3k2525 gold badges202202 silver badges227227 bronze badges
asked Sep 28 "10 at 1:26
*

SeanSean
5,02355 gold badges2121 silver badges2626 bronze badges
4
Add a comment |

7 Answers 7


Active Oldest Votes
58
29 = 512 worths, because that"s exactly how many type of combinations of zeroes and also ones you have the right to have actually.

What those values represent but will depfinish on the device you are using. If it"s an unsigned integer, you will have:

000000000 = 0 (min)000000001 = 1...111111110 = 510111111111 = 511 (max)In two"s enhance, which is typically supplied to recurrent integers in binary, you"ll have:

000000000 = 0000000001 = 1...011111110 = 254011111111 = 255 (max)100000000 = -256 (min) In general, through k bits you deserve to recurrent 2k values. Their range will certainly depend on the system you are using:

Unsigned: 0 to 2k-1 Signed: -2k-1 to 2k-1-1


Share
Improve this answer
Follow
edited Sep 28 "10 at 2:58
answered Sep 28 "10 at 1:29
*

NullUserExceptionNullUserException
79.3k2525 gold badges202202 silver badges227227 bronze badges
2
Add a comment |
10
What you"re missing: Zero is a value


Share
Improve this answer
Follow
answered Sep 28 "10 at 1:27
*

SamStephensSamStephens
5,56366 gold badges3333 silver badges4444 bronze badges
Add a comment |
2
A much better way to deal with it is to start small.

Let"s start via 1 little bit. Which have the right to either be 1 or 0. That"s 2 worths, or 10 in binary.

Now 2 bits, which deserve to either be 00, 01, 10 or 11 That"s 4 values, or 100 in binary... See the pattern?


Share
Improve this answer
Follow
answered Sep 28 "10 at 1:33
*

Randy the DevRandy the Dev
23k66 gold badges4242 silver badges5353 bronze badges
Add a comment |
1
Okay, since it currently "leaked": You"re missing zero, so the correct answer is 512 (511 is the greatest one, but it"s 0 to 511, not 1 to 511).

By the method, an good followup exercise would be to generalize this:

How many various values have the right to be represented in n binary digits (bits)?
Share
Improve this answer
Follow
answered Sep 28 "10 at 1:29
schnaaderschnaader
47.2k99 gold badges9898 silver badges133133 bronze badges
1
Add a comment |
1
Without wanting to offer you the answer right here is the logic.

You have 2 feasible worths in each digit. you have 9 of them.

choose in base 10 wbelow you have actually 10 various worths by digit say you have 2 of them (which makes from 0 to 99) : 0 to 99 provides 100 numbers. if you do the calcul you have an exponential function

base^numberOfDigits:10^2 = 100 ;2^9 = 512
Share
Improve this answer
Follow
answered Sep 28 "10 at 1:30
community wiki
pastjean
Add a comment |
1
There"s an simpler method to think about this. Start with 1 little. This have the right to obviously reexisting 2 worths (0 or 1). What happens as soon as we add a bit? We can currently recurrent twice as many kind of values: the worths we can represent before via a 0 appended and the worths we can recurrent prior to with a 1 appended.

So the the number of worths we have the right to reexisting via n bits is simply 2^n (2 to the power n)


Share
Improve this answer
Follow
answered Sep 28 "10 at 1:32
davedave
11.5k33 gold badges1919 silver badges1212 bronze badges
Add a comment |
1
The point you are missing is which encoding plan is being supplied. Tbelow are different ways to encode binary numbers. Look into signed number representations. For 9 bits, the varieties and also the amount of numbers that deserve to be stood for will differ depending on the device supplied.


Share
Improve this answer
Follow
edited Sep 28 "10 at 1:57
answered Sep 28 "10 at 1:43
James KastrantasJames Kastrantas
7611 silver badge33 bronze badges
5
Add a comment |

Your Answer


Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and also share your research!

But avoid

Asking for aid, clarification, or responding to other answers.Making statements based on opinion; back them up through references or individual experience.

To learn more, check out our tips on creating great answers.

See more: Why Is Oil Coming Out Of My Dipstick, Oil Blowing Out Of Dipstick Tube


Draft saved
Draft discarded

Sign up or log in


Sign up utilizing Google
Sign up using Facebook
Sign up utilizing Email and also Password
Submit

Post as a guest


Name
Email Required, but never before shown


Article as a guest


Name
Email

Required, but never before shown


Article Your Answer Discard

By clicking “Post Your Answer”, you agree to our regards to service, privacy policy and also cookie policy


Not the answer you're looking for? Browse other inquiries tagged binary bits or ask your very own question.


The Overcirculation Blog
Upcoming Events
Featured on Meta
Visit chat
Linked
13
Why is the max integer in java 2^31 - 1 and not 2^31
0
Given N bits, how many kind of integers can be stood for in binary?
0
7-little bit two's complement
Related
934
How to count the number of set bits in a 32-little integer?
13
Java Working via bits
1
Number of Bits per image?
0
Binary digits in decimal
2
How Many Values Can Be Represented With n Digits in Hexadecimal Systems?
2
Three hexadecimal digits deserve to be used to represent 12 binary bits. Why is this sentence true?
0
How can I reexisting all the possible worths of n bits in base 2 making use of n bits in C?
0
Given N bits, how many integers have the right to be stood for in binary?
Hot Netoccupational Questions even more warm inquiries

Question feed
Subscribe to RSS
Question feed To subscribe to this RSS feed, copy and paste this URL right into your RSS reader.


Stack Overflow
Products
Company
Stack Exadjust Network-related
site style / logo design © 2021 Stack Exreadjust Inc; user contributions licensed under cc by-sa. rev2021.10.15.40479


Stack Overcirculation works ideal with JavaScript enabled
*

Your privacy

By clicking “Accept all cookies”, you agree Stack Exreadjust can store cookies on your device and disclose information in accordance via our Cookie Policy.