NumberSystems

Download Report

Transcript NumberSystems

DEC BIN OCT HEX
0 0000
0
0
1 0001
1
1
2 0010
2
2
3 0011
3
3
4 0100
4
4
5 0101
5
5
6 0110
6
6
7 0111
7
7
8 1000
10 8
9 1001
11
9
10 1010
12 A
11 1011
13
B
12 1100
14 C
13 1101
15
D
14 1110
16
E
15 1111
17
F
16 10000 20 10
DEC
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
BIN
10001
10010
10011
10100
10101
10110
10111
11000
11001
11010
11011
11100
11101
11110
11111
100000
OCT HEX
21
22
23
24
25
26
27
30
31
32
33
34
35
36
37
40
11
12
13
14
15
16
17
18
19
1A
1B
1C
1D
1E
1F
20
Decimal to Binary
9410
94/64 =
30/32 =
30/16 =
14/8 =
6/4 =
2/2 =
0/1 =
BASE TWO PLACE VALUE CHART
| 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1R30 1
0R30
1R14
1R6
1R2
1R0
0R0
0
1
9410 = 10111102
1
1
1
0
Decimal to Binary
7210
72/64 =
8/32 =
8/16 =
8/8 =
0/4 =
0/2 =
0/1 =
BASE TWO PLACE VALUE CHART
| 64 | 32 | 16 | 8 | 4 | 2 | 1 |
1R8 1
0R8
0R8
1R0
0R0
0R0
0R0
0
0
7210 = 10010002
1
0
0
0
Decimal to Binary
5110
BASE TWO PLACE VALUE CHART
| 64 | 32 | 16 | 8 | 4 | 2 | 1 |
51/32 = 1R19
19/16 = 1R3
3/8 = 0R3
3/4 = 0R3
3/2 = 1R1
1/1 = 1R0
1
1
5110 = 1100112
0
0
1
1
BINARY TO DECIMAL
Simply add up the binary place values
where there is a one. Try it out on the
last three slides and see how it works.
Try converting the following
1. 11101002
11610
2. 1010112
4310
3. 110100102
21010
4. 100111102
15810
Base two place value chart
| 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 |
EASIEST CONVERSIONS
Binary to Octal and Octal to Binary
Each Base 8 digit has no more than 3 bits in the binary version.
Binary to Octal
Starting from the right, take groups of three bits, convert to base 8.
11010000101111002
= 1502748
001 101 000 010 111 100
1 5 0 2 7 4
Octal to Binary
Write three bits for each Base 8 digit
173608
= 11110111100002
1 7 3 6 0
001 111 011 110 000
EASIEST CONVERSIONS
Binary to Hexadecimal and to Hexadecimal to Binary
Each Base 16 digit has no more than 4 bits in the binary version.
Binary to to Hexadecimal
Starting from the right, take groups of four bits, convert to base 16.
11010000101111002
= D0BC16
1101 0000 1011 1100
D 0
B C
Hexadecimal to Binary
Write three bits for each Base 16 digit
3A4F16
= 111010010011112
3 A
4
F
0011 1010 0100 1111
ONCE BASE 2 CAN BE REACHED FROM
THE OTHER BASES IT IS EASY TO GET
FROM ANY BASE TO ANY OTHER BASE.
9810 = 11000102 = 001 100 010 = 0110 0010
= 1 4 2 = 6 2
=
1428
=
6216
You try these.
DEC
BIN
11101100
236
_________
____
169
111
____
__________
10101001
1101111
__________
OCT
354
_____
251
157
_____
HEX
EC
_____
_____
A9
6F
ADD
SUBTRACT
BASE 16
2A4
+97F
C23
REMEMBER TO
THINK AND SPEAK
WITH BASE 10 NUMBERS
(WE HAVE THE IDEA 10 )
D96
-9AE
3E8
BUT
93E
+6DA
1018
SEE AND WRITE
BASE 16 NUMERALS
(WE SEE AND WRITE A )
93E
-6DA
264
ADD
SUBTRACT
BASE 8
137
+461
620
REMEMBER TO
THINK AND SPEAK
WITH BASE 10 NUMBERS
(WE HAVE THE IDEA 8 )
516
-437
57
BUT
505
+245
752
SEE AND WRITE
BASE 8 NUMERALS
(WE SEE AND WRITE 10 )
500
-245
233
ADD
SUBTRACT
BASE 2
1010
+1110
11000
REMEMBER TO
THINK AND SPEAK
WITH BASE 10 NUMBERS
(WE HAVE THE IDEA 8 )
BUT
SEE AND WRITE
BASE 2 NUMERALS
(WE SEE AND WRITE 1000 )
11010
-1101
1101
To simplify the ALU (arithmetic logic unit) in the CPU,
the only operation the computer performs is addition.
How? By using one’s and two’s complement.---
First, let’s look at base 10 ten’s and nine’s complement
Instead use the ten’s compliment
which is the next higher power of 10. 1000
-283
Ten’s complement - > 717
Add the 10’s compliment to the
top number and throw away the
562
carry.
+717
1279
Easier way: Add 9’s complement + 1
999
So 562
This can be
-283
+717
done easily
Nine’s complement-> 716
1279
in your head.
.
+1 Same as above
717
Subtract: 562
-283
279
Now for the one’s and two’s complement
Subtract: 1001
- 101
100
Instead use the two’s compliment
which is the next higher power of 2.
10000
-101
Two’s complement - > 1011
Add the 2’s compliment to the
top number and throw away the
1001
carry.
+1011
10100
Easier way: Add 1’s complement + 1
1111
This can be
-0101
done easily
One’s complement-> 1010
in your head.
+1
1011
In the CPU the inverter or NOT Circuit
performs the 1’s complement.
So 1001
+1011
10100
Same as above
Easiest method of all coming up next.------------------------------->
Subtract the long way.
10010111
-01101010
00101101
The easy method
10010111
+10010110
100101101
Rules for the easiest method
1. Copy the subtrahend exactly as it
until and including the first one (1)
10
2. After the first one, invert (or NOT)
all bits to the one’s complement.
10010110
3. Now we have the ten’s complement.
Add this to the top number.
4. Discard the carry.
For Practice
Write the two’s complement of these numbers.
1. 100011000
2. 00111100
3. 101010101
011101000
11000100
010101011
Note: Negative numbers in the
computer are stored in
two’s complement form.
Also: In positive binary numbers the last bit to the left is 0.
In negative binary numbers the last bit to the left is 1.