ECE123 Logic Chapter - 1 - Number Systems

Download as pdf or txt
Download as pdf or txt
You are on page 1of 45

ECE123 (CSE255) Logic Circuit Design

Chapter 1

Number Systems

Prof. Fawzy Ibrahim

Electronics and Communication Department


Misr International University (MIU)

1 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


Chapter Contents
1.1 Introduction
1.1.1 Definitions
1.1.2 Data Transfer
1.1.3 Digital Systems Versus Analog
1.1.4 Integrated Circuits ( IC)
1.2 Number Systems
1.2.1 Decimal Number System
1.2.2 Binary Number System
1.2.3 Octal Number System
1.2.4 Hexadecimal Number System
1.2.5 Unknown Base Determination
1.3 Complements
1.4 Signed Binary Numbers
1.5 Binary Arithmetic Operations
1.6 Binary Codes
2 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.1 Introduction 1.1.1 Definitions
1. An analog Quantity is one having continuous values as in Fig. 1.1. Most
natural quantities measurement are analog (temperature, time, distance,
sound,..)
2. Analog or linear electronic circuits: in these circuits voltage levels can vary
continuously ,e.g. transistor amplifier and operational amplifier as shown in
Fig. 1.2.
3. Binary Digits or Bits are ones having only two possible states or values.
These states are represented by two different voltage levels: a High (Logic 1)
and a Low (Logic 0) as shown in Fig. 1.3. The two digits in the binary system,
1 and 0, are called bits.
4. Byte is a group 8 bits (combination of 1’s and 0’s).

Fig. 1.1 Graph of analog quantity Fig. 1.2 An analog circuit


3 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.1 Introduction (Continued) 1.1 Definitions
5. Digital Data or Codes are groups of bits (combination of 1’s and 0’s). They are
used to represent numbers, letters, symbols and anything else required in a
given applications.
6. Digital electronic circuits: The Compact Disk (CD) player is an example in
which both digital and analog circuits are used as shown in Fig. 1.4. Music in
digital format is stored on the compact disk. A laser diode optical system picks
up the digital data from the rotating disk and transfers to the Digital to Analog
Converter (DAC). The DAC changes the digital data into an analog signal
which is amplified and sent to the speaker.
7. The Clock is a periodic waveform as shown in Fig. 1.5 which is used to
synchronize the digital systems.

Fig. 1.4 Basic principle of CD player


Fig. 1.3 Logic Levels

Fig. 1.5 Digital clock


 = pulse width
T = period of the waveform f =1/T
f = frequency of the waveform
4 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.1 Introduction (Continued) 1.1.2 Data Transfer
Data: group of bits that convey some type of information.
Data transfer: data transfer from on circuit to another within the digital system, or
from one system to another to accomplish a given task either in series or in
parallel.
A serial transmission send one line of data from transmitter to receiver as in Fig.
1.6 (a). This method is electronically more simple, making it easier to determine
what is going on, plus it's cheaper. It is, however, slower parallel one.
Parallel transmission uses multiple lines of data to send more information more
quickly as in Fig. 1.6 (b). This method is more complex and more expensive
than serial transmission. Also, it is usually only good for short distance
transmissions of data.

(a)

Fig. 1.6 Data transfer (a) serial; (b) Parallel (b)


5 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.1 Introduction (Continued)
1.1.3 Digital Systems Versus Analog
Digital systems replaced analog systems:
1. Smaller size and less cost with easy maintenance.
2. Efficient and reliable data processing and transmission.
3. Better and larger storage capacity of digital data.
4. More flexible (easy to program), faster, more precise.
5. Built-in error detection and correction
Application of digital circuits:
1. Communications [radio, television, telephones,…..
2. Computers [mainframes, PCs, laptops, super computers, ……
3. Radio navigation, radar systems, and landing systems.
4. Missile guidance and control and airtraffic control systems.
5. Medical instruments [diagnosis, treatment, drug control……
6. Industrial processes control and laboratory equipments.
Digitization:
• Process of conversion from analog to digital is called digitization.
• Analog to Digital Conversion (ADC) performs digitization.
• Digital to Analog Conversion (DAC) regenerates the analog signals from
their digitzed form.
6 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.1 Introduction (Continued)
1.1.4 Integrated Circuits ( IC)
• All logic circuits are available in Integrated Circuits ( IC) form.
• Digital systems have incorporated IC because of their small size, low cost, low
power consumption.
• Two categories of digital ICs:
1. Fixed Function IC: where the logic functions are set by manufacture and can
not be alerted.
2. Programmable logic Devices ( PLD): in which logic functions can be
programmed by user , and in some cases programmed many times

(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

• The decimal numbering system has a base of 10 with each position,


i is weighted by a factor of 10i:

9 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.2 Number Systems (Continued)
1.2.2 Binary Number System
• Base (Radix) = 2
• Digits or the coefficients ai range, in values from 0 to R-1
ai = (0,1)
• Weights = … 23 22 21 20 . 2-1 2-2 2-3 …
• The binary numbering system has a base of 2 with each position
weighted by a factor of 2:

Conversion from any base, R to Decimal Number or base 10


• For positive numbers, the conversion of an m- whole digits and n-
fraction digits, base R integer to the equivalent base10 is
accomplished using equation (1.2) as:
m
( N )10  a R i
i
(1.2)
i  n
10 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.2 Binary Number System
Conversion from Binary to Decimal Number system
Apply equation (1.2) with R = 2 as Follows:
Example 1.1 Convert (1010110)2 to decimal.
Solution (1010110)2 = Σ ai 2i
= 0 x 20 + 1x21 + 1x22 + 0x23 + 1x24 + 0x25 +1x26
= 0 + 2 + 4 + 0 + 16 + 0 + 64 = (86)10
Example 1.2 Convert (11101.01)2 to decimal.
Solution (11101.01)2 = Σ ai 2i
= 1x24 +1x23 +1x22 +0x21 + 1x20 + 0x2-1 + 1x2-2
= 16 + 8 + 4 + 0 + 1 + 0 + ¼ = (29.25)10
Conversion from Decimal to Base R-Number
• In order to convert a decimal integer to an equivalent base-R Integer, each
integer coefficients (a0, a1, a2, …am) of equation (1.2) must be determined.
(N)10 = am Rm + am-1 Rm-1 +….+ a1 R1 + a0 R0 (1.2)
• When both sides of this equation are divided by R, the least significant
coefficient a0 is obtained as the remainder. Subsequent division by R would
yield remaining coefficients a1, a2, a3, and so on, until all of the coefficients
have been determined.
11 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.2 Binary Number System
Conversion from Decimal to Binary Number System
• You can convert a decimal number to binary by repeatedly dividing the by 2,
then the remainder form the binary number.
• You can convert a decimal fraction to binary by repeatedly multiplying the
fractional part or successive multiplications by 2. The carries form the binary
number. 2 624 Remainder
2 312 0 LSB
Example 1.3
2 156 0
Convert (624)10 to is binary equivalent.
2 78 0
Solution
2 39 0
Successive division is carried out to obtain the
remainders. The remainder obtained at the last 2 19 1
step is used as the Most Significant Bit (MSB), 2 9 1
while that obtained in the very beginning is used
2 4 1
as the Least Significant Bit (LSB). The rest of the
remainder fall in between in the order of their 2 2 0
appearance; therefore, 2 1 0
(624)10 = (100111000)2 0 1 MSB

12 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.2 Number Systems (Continued)
1.2.2 Binary Number System
Binary Number
Example 1.4 Decimal
22 21 20
Convert the decimal fraction 0.188 to binary. Number
4 2 1
Solution This conversion is done by repeatedly 0 0 0 0
multiplying the fractional results by 2 as follows: 1 0 0 1
0.188 x 2 = 0.376 carry = 0 MSB 2 0 1 0
3 0 1 1
0.376 x 2 = 0.752 carry = 0
4 1 0 0
0.752 x 2 = 1.504 carry = 1
5 1 0 1
0.504 x 2 = 1.008 carry = 1 6 1 1 0
0.008 x 2 = 0.016 carry = 0 LSB 7 1 1 1
So the answer = 0.00110 (for five significant digits).
• You can convert a decimal whole number to binary by reversing the
procedure. Write the decimal weight of each column and place 1’s in the
columns that sum to the decimal number.
Example 1.5 Convert the decimal number 49 to binary.
Solution 26 25 24 23 22 21 20.
64 32 16 8 4 2 1.
0 1 1 0 0 0 1.
13 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued) Binary
Decimal
1.2.2 Binary Number System Number Number

• A binary counting sequence for numbers from zero N 8421


to fifteen is shown. 0 0000
• Notice the pattern of zeros and ones in each 1 0001
column. 2 0010
• Digital counters frequently have this same pattern 3 0011
of digits:
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
Counter 0 1 0 1 0 1 0 1 0 1 Decoder 10 1010
0 0 1 1 0 0 1 1 0 0 11 1011
0 0 0 0 1 1 1 1 0 0 12 1100
0 0 0 0 0 0 0 0 1 1
13 1101
14 1110
15 1111
14 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.3 Octal Number System
• Base, R = 8
• Digits or the coefficients ai range, in values from 0 to R-1
ai = (0,1,2,3,4,5,6,7)
• Weights = … 83 82 81 80 . 8-1 8-2 8-3 …
Conversion from Octal Number to Decimal Number system
Apply equation (1.2) with R = 8 as Follows:
Example 1.6 Convert (745)8 to decimal.
Solution (N)10 = (745)8 = 5x80 + 4x81 + 7x82 = 5+32+7x64 = (486)10= 486
Example 1.7 Convert (7765)8 to decimal.
Solution (N)10 = (7765)8 = 7  83 + 7  82 + 6  81 + 5  80
= 3584 + 448 + 48 + 5 = (4085)10 = 4085
Example 1.8 (5672)8 to decimal.
Solution (N)10 = (5672)8 = 5x83 + 6x82 + 7x81 + 2x80
= 5x512 + 6x64 + 7x8 + 2x1
= 2560 + 384 + 56 + 2 = (3002)10 = 3002
15 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.3 Octal Number System
Conversion from Decimal to Octal Number System
• You can convert a decimal number to octal by repeatedly dividing it by 8, so
the remainder form the octal number.
• You can convert a decimal fraction to octal by repeatedly multiplying the
fractional part or successive multiplications by 8. The carries form the octal
number.
Example 1.8
Convert (435)10 to is octal equivalent. Remainder
8 435
Solution 8 54 3 LSB
Successive division is carried out to obtain the
remainders. The remainder obtained at the last 8 6 6
step is used as the Most Significant Bit (MSB), 8 0 6 MSB
while that obtained in the very beginning is used
as the Least Significant Bit (LSB). The rest of the
remainder fall in between in the order of their
appearance; therefore,
(435)10 = (663)8

16 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.2 Number Systems (Continued)
1.2.3 Octal Number System
Base Conversion from Binary to Octal Number System and vice versa
• This process is done as follows:
Binary Decimal Octal

Shortcut Method Conversion


• Since 23 = 8, each octal number corresponds to three bits. When the bits of
binary number are grouped into groups of three, starting from the binary point
and grouping to the left and to the right, the equivalent octal number is
obtained by replacing each group of three digits by its octal equivalent.
• To convert from octal to binary, write the three bit binary equivalent of each
octal digit, maintaining the correct digit position.
• Note that to make proper groupings you may have to add zeros to the extreme
left of the integer part and to the extreme right of the fraction part

Example 1.9 Convert (7345.21)8 to binary equivalent.


Solution (7345.21)8 = (111 011 100 101 . 010 001)2 = (111011100101.010 001)2

Example 1.10 Convert (101100011001)2 to octal equivalent.


Solution (101100011001)2 = (101 100 011 001)2 = (5431)8
17 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.4 Hexadecimal Number System
• Base R = 16
• Digits or the coefficients ai range, in values from 0 to R-1.
• ai = (0, 1, …, 9, A, B, C, D, E, F)
Hexadecimal uses sixteen characters to represent numbers: the
numbers 0 through 9 and the alphabetic characters A through F.
• Weights = 163 162 161 160 , 16-1 16-2 16-3 …
Conversion from Hexadecimal to Decimal Number system
Apply equation (1.2) with R = 16 as Follows:
Example 1.11 Convert (A3)16 to decimal equivalent.
Solution
(N)10 = (A3)16 = 3x160 + 10x161 = (163)10 = 163

Example 1.12 Convert (A 5C.4)16 to decimal equivalent


Solution
(N)10 = (A 5C.4)16 = 10x162 + 5x161 + 12 x 160 + 4x16-1
= 10x256 + 5x16 + 12x1 + 4/16 = (2652.25) 10 = (2652.25)
18 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.4 Hexadecimal Number System
Conversion from Decimal to Hexadecimal Number System
• You can convert a decimal number to hexadecimal by repeatedly dividing it
by 16. The remainder form the hexadecimal number.
• You can convert a decimal fraction to hexadecimal by repeatedly multiplying
the fractional or successive multiplications by 16. The carries form the
hexadecimal number.
Example 1.13
Convert (3875)10 to is hexadecimal equivalent
16 3875 Remainder
Solution
16 242 3 LSB
Successive division is carried out to obtain the
remainders. The remainder obtained at the last 16 15 2
step is used as the Most Significant Bit (MSB), 2 0 15 MSB
while that obtained in the very beginning is used
as the Least Significant Bit (LSB). The rest of the
remainder fall in between in the order of their
appearance; therefore,
(3875)10 = (F23)16

19 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.2 Number Systems (Continued)
1.2.4 Hexadecimal Number System
Base Conversion from Binary to Hexadecimal System and vice versa
• This process is done as follows:
Binary Decimal Hexadecimal
Shortcut Method Conversion
• Since 24 = 16, each hexadecimal number corresponds to four bits. When the
bits of binary number are grouped into groups of four, starting from the binary
point and grouping to the left and to the right, the equivalent hexadecimal
number is obtained by replacing each group of four digits by its hexadecimal
equivalent.
• To convert from hexadecimal to binary, write the four bit binary equivalent of
each hexadecimal digit, maintaining the correct digit position.
• Note that to make proper groupings you may have to add zeros to the extreme
left of the integer part and to the extreme right of the fraction part
Example 1.14 Convert (271.A)16 to binary equivalent .
Solution (271.A)16 = (0010 0111 0001 . 1010)2 = (001001110001.1010)2
Example 1.15 Convert (001111110000)2 to hexadecimal equivalent
Solution (001111110000)2 = (0011 / 1111 / 0000)2 = (3F0)16
20 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
1.2.4 Hexadecimal Number System
Base Conversion from Binary to Octal or Hexadecimal System and vice
versa
• This process is done as follows: Octal
Decimal Binary Hexadecimal
Shortcut Method Conversion
Example 1.16 Convert (734.521)8 to binary and hexadecimal equivalent.
Solution
(7345.21)8 = (111 011 100 101 . 010 001)2 = (1110/1110/0101.0100/0100)2
= (EE5.44)16
Example 1.17 Convert (7CD5B)16 to its binary and octal equivalent.
Solution (7CD5B)16 = (0111 1100 1101 0101 1011)2 = (1746533)8

Example 1.18 Convert (0.325)8 to its binary


Solution (0.325)8 = (0.011010101)2

Example 1.19 Convert (0.101110011010)2 to its octal equivalent.


Solution (0.101/110/011/010)2= (0.5632)8
21 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.2 Number Systems (Continued)
Common Number Systems Number Systems
Number Base or Digits or coefficients
System Radix R ai = 0 to R-1
Decimal 10 0, 1, 2, …………9
Binary 2 0, 1
Octal 8 0, 1, 2, …………7
Hexadecimal 16 0, 1, 2, …………9,
A, B, C, D, E, F
Conversion Among Bases

22 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.2 Number Systems (Continued)
1.2.4 Hexadecimal Number System
Base Conversion from Binary to Octal and Hexadecimal System and vice
versa
• This process is done as follows: Octal
Decimal Binary Hexadecimal

Decimal Binary Octal Hexadecimal Decimal Binary Octal Hexadecimal

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

• In digital circuits, the 1’s complement is formed by using inverters as shown.

The input 1 1 0 0 1 0 1 0

1’s Complement 0 0 1 1 0 1 0 1

25 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.3 Complements (Continued)
1.3.2 Two’s (2’s) Complement
• To find the 2’s complement of a binary number, use either:
Method 1: by adding 1 to the least significant bit of the 1’s complement and
ignore the carry out of the sign bit or
Method 2: while scanning the positive number from the right to left, complement
all bits that are encountered after the first one
For example, the 2’s complement of (101101000) is obtained from the 1’s
complement 010010111 by adding 1 to give 010011000

• 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:

27 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.4 Signed Binary Numbers (Continued)
4.2 Sign Magnitude Representation:
1. Representation of Integers
• Typically, unsigned and signed short integer values are stored in 2 bytes, while
unsigned and signed long integer and float numbers are stored in 4 bytes.
• For example, 58 can be represented as a 16-bit binary numeral. For example,
58 can be represented as a 16-bit binary numeral and stored in two bytes as:
58 = (0000000000111010)2
While – 58 is represented as a 16-bit as:

28 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.4 Signed Binary Numbers
4.2 Sign Magnitude Representation
2. Representation of Real Numbers
a) Fixed-Point Numbers Positive Fixed-Point Numbers:
• Fixed-point representation using m integer bits and n fraction bits.
• The binary point is not a part of the representation but is implied.
• The number of integer, m and fraction, n bits must be agreed upon by those
generating and those reading the number.
Example 1.22 Represent + 6.75 as a 8-bit binary Fixed-Point Numbers using 4
integer bits and 3 fraction bits.
Solution 6.75 = 0110.110 = 22+ 21+ 2-1+ 2-2, so the representation of 6.75 (in
Fixed-Point Numbers form) is as follows:

Negative Fixed-Point Numbers:


Negative numbers are stored in 2’s complement form (with a 1 for the sign bit).
Example 1.23 Represent - 6.75 as a 8-bit binary Fixed-Point Numbers using 4
integer bits and 3 fraction bits.
Solution 6.75 = 0110.110, the representation in Fixed-Point Numbers form is:

29 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.4 Signed Binary Numbers (Continued)
4.2 Sign Magnitude Representation:
b) Floating-Point Form
• The binary point floats to the right of the most significant digit.
• Similar to decimal scientific notation:
• For example, 273 in scientific notation is: 273 = 2.73 ×102
• In general, a number is written in scientific notation as: ± M ×Rk
Where: M = mantissa, R = base or radix and k = exponent
• In the example, M = 2.73, R = 10, and k = 2.
• So it is like scientific notation except that the base is 2 rather than 10 as:
a1.a2 a3 ... x 2k
where each ai is 0 or 1, and a1 = 1 (unless the number is 0).
a1.a2 a3 .. is called the mantissa, M.
a1 is the most significant 1, also called the implicit or leading 1
a2 a3 …... is called the fraction and k is called the exponent (or characteristic)

30 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.4 Signed Binary Numbers (Continued)
1.4.3 Floating Point Numbers :
b) Floating-Point Form
• The general form of 32 - bit Floating-Point representation of positive real
number is shown below:

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:

31 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.4 Signed Binary Numbers (Continued)
1.4.3 Floating Point Numbers :
b) Floating-Point Form
Example 1.25:
Represent the real number 228.0 in 32-bit floating-point representation.
Solution 228 can be represented in binary as (111001002)2
Rewriting this in floating-point form: (1.11001002)2 x 27
So: 1.11001002 is the mantissa, 11001002 is the fraction and 7 is the
exponent
Therefore, 32-bit floating-point representation of 228.0 has the form of:

Negative Floating-Point: Negative real numbers are stored in biased exponent


form (with a 1 for the sign bit) as:
Bias for 8 bits = (127)10 = (01111111)2
Biased exponent = bias + exponent
Example: if the exponent = 7 is stored as:
Biased exponent = 127 + 7 = 134 = (10000110)2
32 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.4 Signed Binary Numbers (Continued)
1.4.3 Floating Point Numbers :
• The general form of 32- bit Floating-Point negative real number
representation is shown below:

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

33 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.5 Binary Arithmetic Operations
1.5.1 Binary Addition of Positive Numbers
The rules for binary addition are
0+0=0 Sum = 0, carry = 0
0+1=0 Sum = 1, carry = 0
1+0=0 Sum = 1, carry = 0
1 + 1 = 10 Sum = 0, carry = 1
When an input carry = 1 due to a previous result, the rules are
1 + 0 + 0 = 01 Sum = 1, carry = 0
1 + 0 + 1 = 10 Sum = 0, carry = 1
1 + 1 + 0 = 10 Sum = 0, carry = 1
1 + 1 + 1 = 11 Sum = 1, carry = 1
Add the binary numbers 00111 and 10101 and show the
equivalent decimal addition.
0111
00111 7
10101 21
11100 = 28
34 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.5 Binary Arithmetic Operations (Continued)
1.5.2 Binary Addition with Signed Numbers
• Using the signed number notation with negative numbers in 2’s
complement form simplifies addition and subtraction of signed numbers.
• Rules for addition: Add the two signed numbers. Discard any final carries.
The result is in signed form.
Examples 00011110 = +30 00001110 = +14 11111111 = 1
00001111 = +15 11101111 = 17 11111000 = 8
00101101 = +45 11111101 = 3 1 11110111 = 9
Discard carry
Note that if the number of bits required for the answer is exceeded, overflow will
occur. This occurs only if both numbers have the same sign. The overflow will be
indicated by an incorrect sign bit. Two examples are:
01000000 = +128 10000001 = 127
01000001 = +129 10000001 = 127
10000001 = 126 100000010 = +2
Discard carry
Wrong! The answer is incorrect and the sign bit has changed.
35 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.5 Binary Arithmetic Operations (Continued)
1.5.3 Binary Subtraction with Signed Numbers

• 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:

00011110 (+30) 00001110 (+14) 11111111 (1)


 00001111 –(+15)  11101111 –(17)  11111000 –(8)
2’s complement subtrahend and add:
00011110 = +30 00001110 = +14 11111111 = 1
11110001 = 15 00010001 = +17 00001000 = +8
1 00001111 = +15 00011111 = +31 1 00000111 = +7
Discard carry Discard carry

36 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.5 Binary Arithmetic Operations (Continued)
1.5.4 Binary Multiplication
Example multiplicand 1011
Multiply (1011)2 by (101)2 multiplier 101
Solution _________
since multiplication are repeated addition 1011
and division uses repeated subtraction, it 0000
becomes apparent that the addition process 1011
encompasses all possible arithmetic. ____________
operations within itself. 110111
product
Example 1.20
a) Convert each number to the indicated bases:
(239.25)10 = ( )2 = ( )16
b) Perform the following binary operations:
i) (79)10 - (47)10 using the 2’s complement
ii) (1011111)2 * (101)2
c) How many bits are required to represent the decimal numbers in the range from
0 to 999 using a binary code?
37 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.5 Binary Arithmetic Operations (Continued)
1.5.4 Binary Multiplication
Example 1.20 Solution
a) (239.25)10 = (11101111.01)2= (EF.4)16
b) i) (79)10- (47)10 using the 2’s complement ii) (1011111)2* (101)2

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

38 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.6 Binary Codes (Continued)
• The binary number system has many practical advantages; but in
computer system, most input and output data are in decimal number
system.
• To simplify the communication problem between man and machine, a
number of codes have been derived. Each of these sequence is called a
code word.
• As the code word of n binary digits has 2ⁿ different combinations , it is
necessary for the representation of decimal digits 0,1,……,9 to use at
least 4 binary digits. Since there are 16 combinations of four binary
digits and only 10 of them are used.
• It is possible to form a very large number of codes .There is no
maximum number of bits that may be used for a binary code
representation.
1.6.1 Weighted codes
• The main characteristic is that each binary digit is assigned a “weight”
and for each group of four bits (code word), the sum of the weights of
those binary digits whose value is 1 is equal to the decimal digit which
may represent.
• The codes listed in Table 1.1 are just a sample of the many in use.
39 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.6 Binary Codes (Continued)
1.6.1 Weighted codes
Table 1.1 Examples of weighted binary codes.

Decimal Binary Biquinary


(8421) 4221 2421 84-2-1 5043210
0 0000 0000 0000 0000 0100001
1 0001 0001 0001 0111 0100010
2 0010 0010 0010 0110 0100100
3 0011 0011 0011 0101 0101000
4 0100 1000 0100 0100 0110000
5 0101 0111 1011 1011 1000001
6 0110 1100 1100 1010 1000010
7 0111 1101 1101 1001 1000100
8 1000 1110 1110 1000 1001000
9 1001 1111 1111 1111 1010000
40 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.6 Binary Codes (Continued) Table 1.2 BCD code.
1.6.1 BCD as Weighted code
Decimal Binary BCD
• Binary coded decimal (BCD) is a weighted code 0 0000 0000
that is commonly used in digital systems when it 1 0001 0001
is necessary to show decimal numbers such as 2 0010 0010
in clock displays.
3 0011 0011
• Table 1.2 illustrates the difference between
4 0100 0100
straight binary and BCD. BCD represents each
decimal digit with a 4-bit code. Notice that the 5 0101 0101
codes 1010 through 1111 are not used in BCD. 6 0110 0110
7 0111 0111
Example 1.21 8 1000 1000
Convert each number to the indicated base: 9 1001 1001
(239.25)10 = ( )BCD-code 10 1010 0001 0000
11 1011 0001 0001
Solution 12 1100 0001 0010
(239.25)10 = (001000111001.00100101)BCD-code
13 1101 0001 0011
14 1110 0001 0100
15 1111 0001 0101

41 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim


1.6 Binary Codes (Continued)
1.6.2 Non weighted codes:
• There are many non-weighted codes as listed in table 1.3. The excess-3 or XS3
for short is represented by a binary number three greater than the decimal digit.
• Sometimes it may be necessary for a designer to avoid a number system where
two or more bits change values between successive numbers. The gray, or unit
distance, code is generally chosen during such circumferences
Table 1.3 Examples of non weighted codes.
Decimal Excess – 3 code Gray code
0 0011 0000
1 0100 0001
2 0101 0011
3 0110 0010
4 0111 0110
5 1000 1110
6 1001 1010
7 1010 1000
8 1011 1100
9 1100 1101
42 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.6 Binary Codes (Continued)
Table 1.4 Gray code .
1.6.2 Gray code as a Non Weighted code
Decimal Binary Gray code
• Gray code is an non-weighted code that has a single 0 0000 0000
bit change between one code word and the next in a
1 0001 0001
sequence.
• Gray code is used to avoid problems in systems where 2 0010 0011
an error can occur if more than one bit changes at a 3 0011 0010
time. 4 0100 0110
Binary to gray code conversion: 5 0101 0111
1. The MSB in gray code is the same as the 6 0110 0101
corresponding MSB in the binary number. 7 0111 0100
2. Going from left to, add each adjacent pair of 8 1000 1100
binary code bits to get the next gray code bit. 9 1001 1101
Discard carries.
10 1010 1111
Gray to binary code conversion:
1. The MSB in binary code is the same as the 11 1011 1110
corresponding MSB in the gray number. 12 1100 1010
2. Going from left to, add each binary bit generated 13 1101 1011
to gray code bit in the next adjacent position. 14 1110 1001
Discard carries 15 1111 1000
43 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.6 Binary Codes (Continued)
1.6.3 Error Detecting Codes:
• A parity bit is an extra bit included with a message to make the total number of
1’s either odd or even as shown in Table 1.5. An error detecting code can be
used to detect error during transmission.
Example 1.21
a) Convert : Table 1.5 Examples of Error Detecting Codes.
(1101010100101110) 2 = ( )Gray-code
b) Generate an even parity for message P. Bit Message P. Bit
each of the following messages: (odd) (even)

Message Parity bit 0000 1 0000 0


(A4)16 ? 0001 0 0001 1
(702)8 ? 0010 0 0010 1
Solution
a) (1101010100101110) 2 0011 1 0011 0
= (1011111110111001) Gray-code 0100 0 0100 1
b) An even parity for each message is
0101 1 0101 0
Message Message in Binary P. bit
: : : :
(A4)16 (10100100)2 1
(702)8 (111000010)2 0
44 of 45 ECE123 Ch.1 Number Syatems Prof Fawzy Ibrahim
1.6 Binary Codes (Continued)
Table 1.6 Examples of Alphanumeric codes.
1.6.4 Alphanumeric codes:
Character 7 – bit 8 bit
ASCII code EBCDIC code
• Many applications of digital A 100 0001 1100 0001
computers require the handling of
data that consists not only of B 100 0010 1100 0010
numbers, but also of letters. C 100 0011 1100 0011
• The need to represent more than : : :
64 characters (the lowercase and p 101 0000 1101 0111
upper – case letters and special : : :
control characters for transmission : : :
of digital information) given rise to Z 101 1010 1110 1001
seven – and eight – bit
0 011 0000 1111 0000
alphanumeric codes.
• One such code is known as ASCII 1 011 0000 1111 0001
(American Standard Code For 2 011 0010 1111 0010
Information Interchange) another
3 011 0011 1111 0011
is known as EBCDIC (Extended : : :
BCD Interchange Code) as listed 9 011 1001 1111 1001
in Table 1.6
blank 010 0000 0100 0000
( 010 1000 0100 1101
+ 010 1011 0100 1110
45 of 45 :
ECE123 Ch.1 Number Syatems :Prof Fawzy Ibrahim
:

You might also like