ECE123 Logic Chapter - 1 - Number Systems
ECE123 Logic Chapter - 1 - Number Systems
Chapter 1
Number Systems
(a)
(a) (b)
(C)
Fig. 1.6 Data transfer (a) serial; (b) Parallel
7 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems
In a fixed point, base or Radix–R number system, a number is written as:
(N)R = (am am-1 am-2 …… a0 . a-1 a-2 …. a-n) (1.1)
Integer part radix point fraction part
Where the ai coefficients are o ≤ ai ≤ (R-1)R
ai for: Decimal (0 to 9), Binary (0 and1), Octal (0 to 7), Hexadecimal [0
to F (15)].
• There are m+1 integer digits and n fraction digits. The base, R is
commonly known as the radix of the number system. Any number in
another system with base R can be converted to decimal number
(N)10 as follows:
(N)10 = am Rm + am-1 Rm-1 + … a0R0 + a-1R-1 + a-2 R-2 + … a-n R-n
m
a i Ri (1.2)
i n
Examples: (56.32)10 = 6*100 + 5*101 + 3*10-1 + 2*10-2
(34)8 = 4*80 + 3*81 = (N)10 ( E1)16 = 1*160 + 14*161 = (N)10
(010.11)2 = 0*20 + 1*21 + 0*20 + 1*2-1 + 1*2-2 = (N)10
8 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.1 Decimal Number System
• Base (Radix) R = 10
• Digits or the coefficients ai range, in values from 0 to R-1
ai = (0, 1, 2, …... 8, 9)
• weights …103 102 101 100 . 10-1 10-2 10-3 …
For example N = 7392 can be represented as:
N = 7392 = 2x100 + 9x101 + 3x102 + 7x103
For example N = 402.25 can be represented as:
N = (402.25) = 2x100 + 0x101 + 4x102 + 2x10-1 + 5x10-2
0 0000 0 0 8 1000 10 8
1 0001 1 1 9 1001 11 9
2 0010 2 2 10 1010 12 A
3 0011 3 3 11 1011 13 B
4 0100 4 4 12 1100 14 C
5 0101 5 5 13 1101 15 D
6 0110 6 6 14 1110 16 E
7 0111 7 7 15 1111 17 F
23 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.5 Unknown Base Determination
• Suppose we need to find the base of any mathematical operation of unknown
base, so convert any base to decimal, then solve for the base.
Example: Find the base, R for the following base conversion: (54)R= (69)10.
Solution: To convert any base to decimal, multiply by base to the power, so the
equation will be:
4 x R0+ 5 x R1 = 69 5R + 4 = 69 5R = 65 R =13
So the unknown base R is 13.
Example: Find the base, R for the following base conversion: (213)R= (47)8.
Solution: To convert any base to decimal, multiply by base to the power, so the
equation will be:
3 x R0 + 1 x R1 + 2xR2 = 7 x 80 + 4 x 81 2R2 + R + 3 = 39 2 R2 +R -36= 0
(2R +9)(R-4) = 0 R = 4 (Accepted) and R = -4.5 (Rejected)
So the unknown base R is 4.
Example: Find the base, R for the following operation: (24 +17)R= (40)R.
Solution: To convert any base to decimal, multiply by base to the power, so the
equation will be:
7 x R0 + 1 x R1 + 4 x R0 + 2xR = 0 x R0 + 4 x R1
3R + 11= 4R R = 11
So the unknown base R is 11.
24 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.3 Complements
• Complements are used in digital computers for simplifying the subtraction
operation and for logical manipulation.
1.3.1 One’s (1’s) Complement
• To final the 1’s complement of a binary number, complement every digit, that
is changing each 1 to 0 and each 0 to 1.
For example The 1’s complement of (01001011) is (10110100)
For example, the 1’s complement of 11001010 is
00110101
The input 1 1 0 0 1 0 1 0
1’s Complement 0 0 1 1 0 1 0 1
• In digital circuits, the 1’s complement is formed by using inverters and adders:
1 1 0 0 1 0 1 0
The input
1
0 0 1 1 0 1 0 1
Input bits
Carry
Adder
in (add 1)
Output bits (sum)
2’s Complement 0 0 1 1 0 1 1 0
26 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.4 Signed Binary Numbers
4.2 Sign Magnitude Representation
1. Representation of Integers
• There are several ways to represent signed binary numbers. In all cases, the
MSB in a signed number is the sign bit, that tells you if the number is positive or
negative. Computers use a modified 2’s complement for signed numbers.
Positive Integers: Positive integer are stored in true form (with a 0 for the sign bit)
Example 1.20
Represent + 58 as a 8-bit binary numeral.
Solution 58 is written using 8-bits form as 00111010, the representation (in normal form)
is as follows:
Negative Integers: Negative integer are stored in 2’s complement form (with a 1
for the sign bit).
Example 1.21
Represent - 58 as a 8-bit binary numeral.
Solution 58 is written using 8-bits form as 00111010, the representation of – 58 (in
complement form) is as follows:
Positive Floating-Point: Positive real numbers are stored in true form (with a 0
for the sign bit)
Example1.24:
Represent the real number 22.625, in 32-bit floating-point representation.
Solution 22.625 can be represented in binary as (10110.101)2
Rewriting this in floating-point form: (1.0110101)2 x 24
So: 1.0110101 is the mantissa, 0110101 is the fraction and 4 is the exponent
Therefore, 32-bit floating-point representation of 22.625 has the form of:
Example1.26:
Represent -58.25 in Floating-Point format.
Solution
58.25 = (111010.01)2 = 1. 1101001 × 25
To fill in each field in the 32-bit number:
Sign bit: 1 (negative)
Exponent: 5
Biased exponent bits: (127 + 5) = 13210= (10000100)2
23 fraction bits: (110 1001 0000 0000 0000 0000)2
• Rules for subtraction: 2’s complement the subtrahend and add the numbers.
Discard any final carries. The result is in signed form.
• Repeat the examples done previously, but subtract:
01001111 1011111
11010001 + 101 *
--------------------- ----------------
10 0 1 0 0 0 0 0 1011111
+32 0000000
1011111
----------------------
111011011
c) The number bits that are required to represent the decimal numbers in the
range from 0 to 999 using a binary code is 10-Bits