Binary Numbers

DecimalBinary
Digits0, 1, 2, 3, 4, 5, 6, 7, 8, 90, 1
Expanded Notation825 = 8x102 + 2x101 + 5x100 1011 = 1x23 + 0x22 + 1x21 + 1x20

Binary numbers, like decimal can be seen in the following way. First there is a digit and second there is a place for the digit. For example, in the number 825, 8 is a digit in the 100s place. We can write this as 8x102 (expanded notation). We can then add up all the digits x places to make our number. Likewise we can do this with Binary numbers as well. The number 1000 in Binary can be writen as 1x23.


Conversions

Power
of
Two
Decimal
Value
210
29
28
27
26
25
24
23
22
21
20
2-1
2-2
2-3
2-4
2-5
26
1024
512
256
128
64
32
16
8
4
2
1
0.5
0.25
0.125
0.0625
0.03125
0.015625
Decimal
Number
Binary
Number
16 8 4 2 1
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
0 0 0 0 0
0 0 0 0 1
0 0 0 1 0
0 0 0 1 1
0 0 1 0 0
0 0 1 0 1
0 0 1 1 0
0 0 1 1 1
0 1 0 0 0
0 1 0 0 1
0 1 0 1 0
0 1 0 1 1
0 1 1 0 0
0 1 1 0 1
0 1 1 1 0
0 1 1 1 1
1 0 0 0 0
1 0 0 0 1
1 0 0 1 0
1 0 0 1 1
1 0 1 0 0
Conversion to and from binary, decimal, octal, and hexidecimal are easy and very mechanical. To convert into/from octal and hexidecimal you must first convert into binary. So this is how we convers decimal to binary.

Example:
         825 in decimal = ?????? in binary

         825 / 2 = 412 R 1
         412 / 2 = 206 R 0
         206 / 2 = 103 R 0
         103 / 2 =  51 R 1
          51 / 2 =  25 R 1
          25 / 2 =  12 R 1
          12 / 2 =   6 R 0
           6 / 2 =   3 R 0
           3 / 2 =   1 R 1
           1 / 2 =   0 R 1

                        = 1100111001 in binary
Simply we divide by 2 repeatedly and keep track of the remainders. Then we write out the remainders in reverse order and we have our binary number. It is important to remember which order your list of 0's and 1's is to be printed. THe easiest way I find to do this is to remember that the pattern can be continued forever, that is 0/2 = 0 R 0 as such we can end up with as many 0's as we want. And as we all know 0's at the start of a number have no effect on the number's value.

Converting numbers less than 0 is simular. This time, we multiply by 2 instead of dividing. So again by example, lets take then number 0.78125.

Example:
         0.78125 in decimal = ?????? in binary

         0.78125 x 2 = 1.56250
         0.5625  x 2 = 1.1250
         0.125   x 2 = 0.250
         0.25    x 2 = 0.50
         0.5     x 2 = 1.0

                        = 0.11001 in binary
Again it is important to remember what order your answer is in. Again this pattern can continue on forever, and as we all learnt in grade 2, you can put as many 0's at the end of a decimal and the value will not change.

Just like in decimal, not all numbers are representable in binary. For example sqrt(2) in decimal is not representable in decimal which you should have proven in MATH 271. Likewise the number 0.1 in decinmal, cannot be represented in binary. Lets try to do it.

Example:
         0.1 in decimal = ?????? in binary

         0.1 x 2 = 0.2
         0.2 x 2 = 0.4 <---,
         0.4 x 2 = 0.8     |
         0.8 x 2 = 1.6     |
         0.6 x 2 = 1.2     |
         0.2 x 2 = 0.4 >---'

                        = 0.0001100110011001100110011...... in binary
So here we can see the repeating pattern, that we will loop in forever and as such not all real numbers can be represented.

Converting from Binary to Decimal is even easier. Since we know the values for all placeholders all we have to do is add them up.

6432168 4 2 1
0110001 = 32 + 16 + 1 =49
1100110 = 64 + 32 + 4 + 2 =102
0010100 = 16 + 4 =20

All you do for Binary to Decimal conversions is add up all the places. The same is for decimal numbers such as 34.675.