02- Operation of Number Systems
02- Operation of Number Systems
2 From 38
Common Powers (1 of 2)
Base 2:
Power Memory Size Symbol Value (Byte) Value (Bits)
20 One byte 1B 1 8
210 One kilobyte 1 KB 1,024 8,192
220 One megabyte 1 MB 1,048,576 8,388,608
230 One gigabyte 1 GB 1,073,741,824 8,589,934,592
240 One terabyte 1 TB 1,099,511,627,776 8,796,093,022,208
250 One petabyte 1 PB 1,125,899,906,842,624 9,007,199,254,740,992
260 One exabyte 1 EB 1,152,921,504,606,846,976 9,223,372,036,854,775,808
270 One zettabyte 1 ZB 1,180,591,620,717,411,303,424 9,444,732,965,739,290,435,072
4 From 38
Data Size Conversions (1 of 2)
✓ Formula:
From Unit To Unit Conversion Factor Kilobytes (KB)×1,024=Bytes (B)
✓ Example:
Kilobytes Bytes 1 KB = 1,024 B Convert 5 KB to Bytes:
5 KB × 1,024=5,120 Bytes
Megabytes Kilobytes 1 MB = 1,024 KB
✓ Formula:
Gigabytes Megabytes 1 GB = 1,024 MB Megabytes (MB)×1,024=Kilobytes (KB)
✓ Example:
Terabytes Gigabytes 1 TB = 1,024 GB
Convert 3 MB to KB:
3MB × 1,024=3,072 KB
5 From 38
Data Size Conversions (2 of 2)
6 From 38
Example
In the lab:
▪ Double click on My Computer
▪ Right click on C:
▪ Click on Properties
7 From 38
Exercise – Free Space
Free space
Drive
Bytes GB
A:
C:
D:
E:
etc.
8 From 38
Binary Addition (1 of 2)
A B A+B
0 0 0
0 1 1
1 0 1
1 1 10
“two” 9 From 38
Binary Addition (2 of 2)
10 From 38
Multiplication (1 of 2)
11 From 38
Multiplication (2 of 2)
✓ Binary to decimal
o Example
15 From 38
Binary Digital Codes
✓ BCD
✓ BCD XS 3 – BCD Excess 3 code
✓ Gray Code
16 From 38
Binary Coded Decimal (BCD)
17 From 38
BCD – Binary Coded Decimal
6 3 4 9
0110 0011 0100 1001
18 From 38
BCD Examples
10 0001 0000
121 0001 0010 0001
234 0010 0011 0100
1003 0001 0000 0000 0011
19 From 38
GRAY CODE
20 From 38
Binary-to-Gray code conversion
✓ The MSB in the Gray code is the same as corresponding MSB in the binary number.
✓ Going from left to right, add each adjacent pair of binary code bits to get the next
Gray code bit. Discard carries.
Example: convert 101102 to Gray code
1 + 0 + 1 + 1 + 0 Binary
Gray 1 1 1 0 1
21 From 38
The Gray Code
✓ The MSB in the binary code is the same as the corresponding bit in the Gray code.
✓ Add each binary code bit generated to the Gray code bit in the next adjacent position.
Discard carries.
Example: convert the Gray code word 11011 to binary
1 1 0 1 1 Gray
+ + + +
Binary 1 0 0 1 0
23 From 38
Alphanumeric Codes
24 From 38
ASCII
25 From 38
Sign Magnitude
x xxx xxxx
✓ A 0 in the sign bit means positive, and a 1 means
negative
26 From 38
Sign Extension - complement
000000000xxxxxxx
9 9 9 9 9 9
✓ Find the 9’s complement of
✓
546700 and 12389
The 9’s complement of 546700 is
- 5 4 6 7 0 0
9 9 9 9 9
✓ and the 9’s complement of 12389
is 99999- 12389 = 87610. - 1 2 3 8 9
8 7 6 1 0
28 From 38
10’s complement Examples
is:
4 5 3 3 0 0
1000000 - 546700= 453300
✓ and the 10’s complement of
12389 is: 1 0 0 0 0 0
complement + 1. 8 7 6 1 1 29 From 38
2’s complement
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
30 From 38
2’s complement Example
1 0 0 0 0 0 0 0
✓ The 2’s complement of 1011001
is: 0100111
- 1 0 1 1 0 0 1
0 1 0 0 1 1 1
1 1 1 0 0 0 1
31 From 38
1’s complement
1 1 1 1 1
- Digit
n
Digit
n-1
Next
digit
Next
digit
First
digit
32 From 38
1’s complement
33 From 38
1’s complement
1 1 1 1 1 1 1
✓ The complement 1’s of
1011001 is 0100110
- 1 0 1 1 0 0 1
0 1 0 0 1 1 0
1 1 1 1 1 1 1
✓ The 1’s complement of
0001111 is 1110000 - 0 0 0 1 1 1 1
1 1 1 0 0 0 0
34 From 38
34
Fast Methods for 2’s Complement
✓ Method 1:
✓ The 2’s complement of binary number is obtained by
adding 1 to the l’s complement value.
✓ Example:
✓ 1’s complement of 101100 is 010011 (invert the 0’s
and 1’s)
✓ 2’s complement of 101100 is 010011 + 1 = 010100
35 From 38
35
Fast Methods for 2’s Complement
✓ Method 2:
✓ The 2’s complement can be formed by leaving all least significant
0’s and the first 1 unchanged, and then replacing l’s by 0’s and 0’s
by l’s in all other higher significant bits.
✓ Example:
✓ The 2’s complement of 1101100 is 0010100
✓ Leave the two low-order 0’s and the first 1 unchanged, and then
replacing 1’s by 0’s and 0’s by 1’s in the four most significant bits.
36 From 38
36
Exercise
0011010 ?
? 101100110
101010010 ?
? 10010010011
37 From 38
AT THE END!
38 From 38