Learn

Let’s reinforce what we learned in the previous exercise by practicing our counting to eight in binary. Eight may seem like a random number to stop at, but check out the table below and try to pick up the pattern of the counting.

Decimal Binary
0 0
1 1
2 10
3 11
4 100
5 101
6 110
7 111
8 1000

Each time we reach a power of two we have to add another digit. For example, when we reach the number `2` or 21, the binary value goes from `1` to `10`.

Similarly, when we reach decimal `4` (22), in binary we go from `11` to `100`. This pattern continues for all the powers of 2 (0, 2, 4, 8, 16, 32, 64, 128, etc).

In fact, this brings us to our first trick to figuring out a number in binary. The highest a binary number can be is 2n - 1, where `n` is the number of digits in the binary number.

`011010001010` is 12 digits long; therefore, the highest number that can be represented in binary with these digits is `4095`:

212 - 1 = 4095

If we changed all the digits of our 12-digit binary number to `1`s, we get `4095` in decimal.

``111111111111 = 4095``

Our next trick you may have picked up yourself. You will notice that all odd numbers in binary end in `1` and all even numbers end in `0`. This is a quick way to double-check your work.

### Instructions

1.

Create a variable called `answer1` and set it equal to the highest numerical value that can be represented in a 13-bit binary number, eg `1111111111111`.

2.

Now let’s try two more! Create two more variables called `answer2a` and `answer2b` and set them equal to the highest numerical value that can be represented in a 5-bit binary number and a 15-bit number respectively.

3.

Finally, create two more variables, `answer3a` and `answer3b`. Set `answer3a` equal to the MSB and `answer3b` to the LSB of the binary number `011100100011`.