0

I was reading the Wikipedia page on counting in binary and came across this statement that I don't quite understand:

In the binary system, each digit represents an increasing power of 2, with the rightmost digit representing 2$^0$, the next representing 2$^1$, then 2$^2$, and so on.

So does this mean that as we increase the number of digits, we increase in powers of 2? 2$^0$ is represented by 0001, 2$^1$ by 0010, 2$^2$ by 0100, and 2$^3$ by 1000?

I know with the decimal system, 10$^2$ gives me 100 available numbers. In binary, 2$^2$ (which equals 4) gives me this: 0, 1, 10, 11 (4 available numbers). But 2$^3$ (which equals 8) gives me this: 0, 1, 10, 11, 100, 101, 111 which is only 7 numbers. I'm not sure what I'm missing, in the decimal system we keep track of orders of magnitude with 10$^n$, but in binary is it 2$^n$-1?

Attila
  • 123
  • 5
    What do have against 110? – saulspatz Apr 04 '18 at 05:21
  • 2
    Poor, neglected $110$! As Ernie said to Bert "6 is nobody's favorite number". But's no reason to pretend it doesn't exist. – fleablood Apr 04 '18 at 05:25
  • 1
    You forgot 110 tho. Sed ,what'd it ever do to you – The Integrator Apr 04 '18 at 05:29
  • 1
    @fleablood but 6 is perfect! – Angina Seng Apr 04 '18 at 05:44
  • I always that Sesame Street was way off on that song. If 6 is a relatively less popular favorite number its only because of the abundance of choices (and surely 6 is more popular than 2 and 8 isn't it). And 6 is certainly one of the more interesting numbers. It seems it'd be more fitting if Bert's favorite number was 1. – fleablood Apr 04 '18 at 15:50
  • Ah, I'm so silly... so 2$^n$ does give the correct number of digits to play with. Why do we start these number systems with x$^0$ though? It will always give us 1. 2$^0$ only gives us 1 digit, the number 1. 2$^1$ gives us the available symbols to use in the system: 0 and 1. Just like how 10$^1$ gives us 10, which is how many digits/ symbols we have to use in that system (0-9). – Attila Apr 04 '18 at 17:34
  • $n$ bits will give us $0$ (zero) to $2^n - 1$ which, including zero are $2^n$ numbers. With zero bits we can only get $0$ (which is the default of not setting anything). Which is $2^0 = 1$ number. But it is not the number $1$. It is the number $0$. And we can get all the numbers from $0$ to $2^0 - 1 = 0$. $0$ to $0$. So all the rules work. – fleablood Apr 04 '18 at 19:10

1 Answers1

1

It looks like you might have fudged your math a bit (pun intended). It happens when learning new bases. No biggy.

\begin{array}{c|l|c} \text{Base 10}& \text{Conversion} & \text{Binary}\\ \hline 1 & 2^0 & 001 \\ 2 & 2^1 & 010 \\ 3 & 2^1 + 2^0 & 011 \\ 4 & 2^2 & 100 \\ 5 & 2^2 + 2^0 & 101 \\ 6 & 2^2 + 2^1 & 110 \\ 7 & 2^2 + 2^1 + 2^0 & 111 \end{array}

With $n$ bits the max you can get to is $2^n-1$, or in this case, the max that you can reach is seven. Since, $2^3 - 1 = 8 - 1 = 7$. If you want to reach 8, then you'll have to add another bit.

Jordan
  • 74
  • Yes, but as we are considering $0$ we do get $2^n$ values. S/he counted 0 to 3 correctly as 4 numbers, but counted 0, to 7 as 7 by leaving out the 6 and did consider that for binary the $b^n$ rule ight actually be different for $2$. – fleablood Apr 04 '18 at 15:53
  • @fleablood yes, I see. I was touching on the fact that the highest number (max) that you can count to could be given as $2^n -1$. If you have 3 bits you include 0 you do get 8 values, but you can only count to 7. It’s an important concept to understand since you will eventually need to be considering overflow. If someone said, “How high can you count with 256 bits?” It’s easy to calculate with this rule $2^n - 1$ where $n$ is the number or bits. I thought this was initially where s/he may have seen the rule $2^n - 1$ pop up, and was confused because they were conflating it with some exercise. – Jordan Apr 04 '18 at 17:15
  • You could be right. And s/he may have figure that as 111 = 7 there were only seven values (by forgetting about 0) and when she listed them $000, 001, ... 111$ s/he miscounted as $7$ it's reasonable the confabulated the two concepts to get that she only had $7$ in her list. In actuality, of course, s/he simply let one out. – fleablood Apr 04 '18 at 19:05