# The Binary Number System

Document Sample

```					                The Binary Number System
• Numbers have positional importance
•              349.2510

9 x 100 = 9 x 1 = 9     2 x 10-1 = 2/10
5 x 10-2 = 5/100
4x    101   = 4 x 10 = 40

3 x 102 = 3 x 100 = 300

In the binary system, positional importance follows
powers of 2
Binary Numbers
•             1 0 1 1. 0 1 2
1 x 2-2 = 1/4
0 x 2-1 = 0
1 x 20 = 1 x 1 = 1
1 x 21 = 1 x 2 = 2
0 x 22 = 0 x 4 = 0

1 x 23 = 1 x 8 = 8

1 0 1 1. 0 1 2 = 11-1/410 = 11.2510
Counting in Base 2
Base 10   Base 2              Base 10    Base 2
0   0                         8    1000
1   1                         9    1001
2   10                        10   1010
3   11                        11   1011
4   100                       12   1100
5   101                       13   1101
6   110                       14   1110
7   111                       15   1111
Powers of 2
•   20 = 1
•   21 = 2       2-1 = 1/2
•   22 = 4       2-2 = 1/4
•   23 = 8       2-3 = 1/8
•   24 = 16      2-4 = 1/16
•   25 = 32      2-5 = 1/32
•   26 = 64      2-6 = 1/64
•   27 = 128     2-7 = 1/128
•   28 = 256     2-8 = 1/256
•   29 = 512     2-9 = 1/512
•   210 = 1024   2-10 = 1/1024   210 = 1024 = 1K
A Heuristic Way to Convert
Decimal to Binary
• Consider that you have the powers of 2 (like pool balls).
Put a “1” in the right position to include them and
put a “0” in the right position to omit them
• 25 24 23 22 21 20 . 2-1 2-2
• 32, 16, 8, 4, 2, 1 . 1/2, 1/4
• What is the binary representation of 40.7510?

40 = 32 + 8            0.75 = 1/2 + 1/4
40.7510 = 101000.112
A Structured Way to Convert
Decimal to Binary
• X10 = abcdef2     (a,b,c,d,e,f)(0,1)
• X10 = a25 + b24 + c23 + d22 + e21 + f20
• Divide by two

X/2 = a24 + b23 + c22 + d21 + e20       +       f
Quotient (call it Y)                 Remainder

The first remainder after dividing by 2 is the least
significant bit of the binary representation
Continued division
• X/2 = a24 + b23 + c22 + d21 + e20       +         f
Quotient (call it Y)                    Remainder

• Y/2 = a23 + b22 + c21 + d20        +        e

The second remainder after dividing by 2 is the
coefficient of 21 in the binary representation

 Continue dividing and saving remainders
An Example
• What is the binary representation of 6110?

•   61/2 = 30 with a remainder of    1
•   30/2 = 15 with a remainder of    0
•   15/2 = 7 with a remainder of     1
•   7/2 = 3 with a remainder of      1
•   3/2 = 1 with a remainder of      1
•   1/2 = 0 with a remainder of      1

Read remainders from last to first
6110 = 1111012

6110 = 1111012             Is this the right answer?

1111012 =

1 + 4 + 8 + 16 + 32 = 61
A Structured Way to Convert
Decimal to Binary
• Represent a decimal fraction as binary digits
0.y10 = 0.abcde2     (a,b,c,d,e,f) (0,1)
• 0.y10 = a2-1 + b2-2 + c2-3 + d2-4 + e2-5
• Multiply by two
0.y*2 =         a               + b2-1 + c2-2 + d2-3 + e2-4
an integer      +    a fraction

The first integer after multiplying by 2 is the most
significant bit of the binary representation of a fraction
Continued multiplication
• 0.y*2 =      a                  + b2-1 + c2-2 + d2-3 + e2-4
an integer            + a fraction (call it z)

• z*2 =        b    +      c2-1 + d2-2 + e2-3

The second integer after multiplying by 2 is the
coefficient of 2-2 in the binary representation

 Continue multiplying and saving integers
An Example
• What is the binary representation of 0.0625?

•    0.0625 * 2 =         0         .125
•    0.125 * 2 =          0         .250
•    0.250 * 2 =          0         .500
•    0.500 * 2 =          1         .000

Read integers from first to last
.062510 = .00012       (1/16)
The result is sometimes a continued fraction
•   What is the binary representation of 0.6510?
•   0.65 * 2 = 1        .30
•   0.30 * 2 = 0        .60
•   0.60 * 2 = 1        .20
•   0.20 * 2 = 0        .40
•   0.40 * 2 = 0        .80
•   0.80 * 2 = 1        .60
•   0.60 * 2 STOP! This would continue forever.

• 0.65 = 0.101001
(the overbar indicates the digits to be repeated)

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 63 posted: 9/4/2010 language: English pages: 13