Professional Documents
Culture Documents
Icoa Ch2 Number Sys Codes - 1. No Sys
Icoa Ch2 Number Sys Codes - 1. No Sys
Lecture 2-1
Number Systems and Data Representation
Outline
Count in binary, octal and hexadecimal number systems.
Understand the weighting structure of numbers.
Perform base conversion of various number systems.
Carry out arithmetic operations with binary numbers.
copyright 2009 Mok KM
Number System
Digital systems process data in binary format.
Need to represent information in binary
For manipulation in electronic hardware
A number system consists of an ordered set of symbols called digits.
Total number of digits = base (radix, R) of a number system
The range of numbers is 0 to (R - 1). Decimal Binary Octal Hexadecimal
The number can have 2 parts: 0 0 0 0
- Integer
1 1 1 1
- Fractional
2 10 2 2
- Separated by a radix point (.)
3 11 3 3
- E.g. (an-1 an-2 ... a1 a0 . a-1 a-2 ... a-m)R 4 100 4 4
Commonly used number systems in digital 5 101 5 5
electronics field of study 6 110 6 6
Decimal number system: 7 111 7 7
- Digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9} 8 1000 10 8
- R = 10. 9 1001 11 9
Binary number system: 10 1010 12 a
- Digits {0, 1} 11 1011 13 b
- R = 2. 12 1100 14 c
Hexadecimal number system: 13 1101 15 d
- Digits {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F} 14 1110 16 e
- R = 16.
15 1111 17 f
Octal number system:
16 10000 20 10
- Digits {0, 1, 2, 3, 4, 5, 6, 7}
- R = 8.
copyright 2009 Mok KM
Counting in Binary
How to count in binary?
0 First column is full
1 Reset first column and add 1 to second column
10 First two columns are full
11 Reset and add 1 to third column
100
101
110
111 First three columns are full
1000 Reset and add 1 to fourth column
1001
Where
. = radix point. E.g. binary point, hex point, decimal point.
R = radix or base - any positive integer where R > 1
n = number of integer digits (left of radix pt)
m = number of fractional digits (right of radix pt)
an-1 = most significant digit (MSD)
a-m = least significant digit (LSD)
Solution 1
1010.1012 = (1 X 23) + (0 X 22) + (1 X 21) + (0 X 20) + (1 X 2-1) + (0 X 2-2) + (1 X 2-3)
= 810 + 0 + 210 + 0 + 0.510 + 0 + 0.12510
= 10.62510
Example 2
Convert 6278 to ?10.
Solution 2
6278 = (6 X 82) + (2 X 81) + (7 X 80)
= 38410 + 1610 + 710
= 40710
copyright 2009 Mok KM
Base Conversion:
Convert Integer Decimal (Base 10) to Base N
Example 1: Method 1 Example 2: Method 2 - Divide-by-
Convert 4910 to a binary number. radix
Convert 4910 to a binary number.
Solution 1
49 32 = 17 Solution 2
17 16 = 1 49 / 2 = 24 remainder 1 (LSB)
1 1 = 0 (conversion completed) 24 / 2 = 12 remainder 0
12 / 2 = 6 remainder 0
6/2 =3 remainder 0
3/2 =1 remainder 1
64 32 16 8 4 2 1 1/2 =0 remainder 1 (MSB)
1 1 0 0 0 1
Solution 1
0.828125 0.5 = 0.328125
0.328125 0.25 = 0.078125
0.078125 0.0625 = 0.015625
0.015625 0.015625 = 0 (conversion completed)
Solution 2
MSB 1.656250 <- 0.828125 X 2
1.312500 <- 0.656250 X 2
0.626000 <- 0.312500 X 2
1.250000 <- 0.625000 X 2
0.500000 <- 0.250000 X 2
LSB 1.000000 <- 0.500000 X 2
Example 1:
Convert 18.69 to ?11.
Solution 1
Convert 18.69 to base 10:
18.69 = (1 X 91) + (8 X 90) + (6 X 9-1)
= 9 + 8 + 0.666
= 17.66610
Convert from base 10 to base 11 using the divide-by-radix and multiply-by-radix method:
17 / 11 = 1 remainder 6
1 / 11 = 0 remainder 1
Solution 1
Since 8 = 23, we can group three binary digits for each octal digit.
Therefore, 1_011_011.101_011_12 = 133.5348
Example 2
Convert AF.16C16 to base 8.
Solution 2
Since 16 is not a power of base 8. But both bases are a power of 2.
Therefore, we can convert AF.16C16 to base 2 and then convert to base 8.
Binary Arithmetic
4 basic types of binary arithmetic:
Binary addition
Binary subtraction
Binary multiplication
Binary division
copyright 2009 Mok KM
Binary Addition
Example 1 How does the above information relate
Add 11110 and 1100. to circuit?
Understand the process of binary
addition leads to constructing an adder
Solution 1 circuit for each bit
1 1 1 1 0 Augend Then combine the adders to compute
1 1 1 0 0 0 Carries two n-bit numbers
+ 0 1 1 0 0 Addend Need to capture the info into an
0 1 0 1 0 Sum
intermediate form first e.g. truth table
before proceed to adder circuit design.
Binary Subtraction
Example 1
Subtract 101110 from 1100101.
Solution 1
1 1 0 0 1 0 1 Minuend
0 1 1 1 1 1 0 0 Borrows
- 0 1 0 1 1 1 0 Subtrahend
0 1 1 0 1 1 1 Difference
Binary Multiplication
Example 1
Multiply 10111 by 1010.
Solution 1
10 1 11 Multiplicand
X 1 0 10 Multiplier
00 0 00 First partial product
1 01 1 1 Second partial product
00 00 0 Third partial product
101 11 Fourth partial product
111 00 110 Product
Binary Division
Example 1
Divide 111101 by 1001.
Solution 1
110 Quotient
Divider 1 0 0 1 1 1 1 1 0 1 Dividend
1001
1100
1001
111 Remainder