UNIT IV Number System
UNIT IV Number System
UNIT IV Number System
ELECTRONICS
B.Tech (ALL)
Notes
Now a day’s digital systems are used in wide variety of industrial and consumer products such as
automated industrial machinery, pocket calculators, microprocessors, digital computers, digital watches,
TV games and signal processing and so on.
Characteristics of Digital systems
Digital systems manipulate discrete elements of information.
Discrete elements are nothing but the digits such as 10 decimal digits or 26 letters of alphabets and
so on.
Digital systems use physical quantities called signals to represent discrete elements.
In digital systems, the signals have two discrete values and are therefore said to be binary.
A signal in digital system represents one binary digit called a bit. The bit has a value either 0 or 1.
Analog system process information that varies continuously i.e; they process time varying signals
that can take on any values across a continuous range of voltage, current or any physical parameter.
Digital systems use digital circuits that can process digital signals which can take either 0 or 1 for
binary system.
age no. 1
Advantages of Digital system over Analog system
1. Ease of programmability
The digital systems can be used for different applications by simply changing the program without
additional changes in hardware.
The cost of hardware gets reduced by use of digital components and this has been possible due to
advances in IC technology. With ICs the number of components that can be placed in a given area of
Silicon are increased which helps in cost reduction.
3. gh speed
Digital processing of data ensures high speed of operation which is possible due to advances in
Digital Signal Processing.
4. High Reliability
Digital systems are highly reliable one of the reasons for that is use of error correction codes.
5. Design is easy
The design of digital systems which require use of Boolean algebra and other digital techniques is
easier compared to analog designing.
Since the output of digital systems unlike analog systems is independent of temperature, noise,
humidity and other characteristics of components the reproducibility of results is higher in digital systems
than in analog systems.
R S PATHAK
NUMBER SYSTEM
Number system is a basis for counting varies items. Modern computers communicate and operate
with binary numbers which use only the digits 0 &1. Basic number system used by humans is Decimal
number system.
For Ex: Let us consider decimal number 18. This number is represented in binary as 10010.
We observe that binary number system take more digits to represent the decimal number. For large
numbers we have to deal with very large binary strings. So this fact gave rise to three new number systems.
The base decides the total number of digits available in that number system.
First digit in the number system is always zero and last digit in the number system is always
base-1.
The left most bit, which has the greatest weight is called the Most Significant Bit (MSB). And the
right most bit which has the least weight is called Least Significant Bit (LSB).
R S PATHAK
For Ex: 1001.012 = [ ( 1 ) × 23 ] + [ ( 0 ) × 22 ] + [ ( 0 ) × 21 ] + [ ( 1 ) × 20 ] + [ ( 0 ) × 2-1 ] + [
( 1 ) × 22 ]
1001.012 = [ 1 × 8 ] + [ 0 × 4 ] + [ 0 × 2 ] + [ 1 × 1 ] + [ 0 × 0.5 ] + [ 1 × 0.25 ]
1001.012 = 9.2510
The decimal system has ten symbols: 0,1,2,3,4,5,6,7,8,9. In other words, it has a base of 10.
Digital systems operate only on binary numbers. Since binary numbers are often very long, two
shorthand notations, octal and hexadecimal, are used for representing large binary numbers. Octal systems
use a base or radix of 8. It uses first eight digits of decimal number system. Thus it has digits from 0 to 7.
R S PATHAK
=2095.093710
vi) Decimal to Octal Conversion
8 | 378
|
8 |47 --- 2
|
8 |5 --- 7 ↑
|
0 --- 5
=5728
0.9310 to octal :
0.93x8=7.44
0.44x8=3.52 ↓
0.53x8=4.16
0.16x8=1.28
=0.73418
378.9310=572.73418
vii) Hexadecimal to Decimal Conversion
Ex: 5C716 to decimal
=1280+192+7
=14710
viii) Decimal to Hexadecimal Conversion
Ex: 2598.67510
1 6 2598
16 162 -6
10 -2
= A26 (16)
R S PATHAK
0.67510=0.675x16 -- 10.8
=0.800x16 -- 12.8 ↓
=0.800x16 -- 12.8
=0.800x16 -- 12.8
=0.ACCC16
2598.67510 = A26.ACCC16
The simplest way is to first convert the given octal no. to binary & then the binary no. to
hexadecimal.
Ex: 756.6038
7 5 6 . 6 0 3
111 101 110 . 110 000 011
0001 1110 1110 . 1100 0001 1000
1 E E . C 1 8
First convert the given hexadecimal no. to binary & then the binary no. to octal.
Ex: B9F.AE16
B 9 F . A E
1011 1001 1111 . 1010 1110
101 110 011 111 . 101 011 100
5 6 3 7 . 5 3 4
=5637.534
Complements:
In digital computers to simplify the subtraction operation & for logical manipulation complements
are used. There are two types of complements used in each radix system.
R S PATHAK
Representation of signed no.s binary arithmetic in computers:
Ex:
0 1 0 1 0 0 1
↓
Sign bit =+41 magnitude
↑
1 1 0 1 0 0 1
= -41
Note: manipulation is necessary to add a +ve no to a –ve no
Ex:
Given no. Sign mag form 2‘s comp form 1‘s comp form
01101 +13 +13 +13
010111 +23 +23 +23
10111 -7 -7 -8
1101010 -42 -22 -21
R S PATHAK
Special case in 2’s comp representation:
Whenever a signed no. has a 1 in the sign bit & all 0‘s for the magnitude bits, the decimal
equivalent is -2n , where n is the no of bits in the magnitude .
Ex: 1000= -8 & 10000=-16
Decimal Sign 2‘s comp form Sign 1‘s comp form Sign mag form
+7 0111 0111 0111
+6 0110 0110 0110
+5 0101 0101 0101
+4 0100 0100 0100
+3 0011 0011 0011
+2 0010 0010 0010
+1 0011 0011 0011
+0 0000 0000 0000
-0 -- 1111 1000
-1 1111 1110 1001
-2 1110 1101 1010
-3 1101 1100 1011
-4 1100 1011 1100
-5 1011 1010 1101
-6 1010 1001 1110
-7 1001 1000 1111
8 1000 -- --
R S PATHAK
Methods of obtaining 2’s comp of a no:
In 3 ways
1. By obtaining the 1‘s comp of the given no. (by changing all 0‘s to 1‘s & 1‘s to 0‘s) &
then adding 1.
2. By subtracting the given n bit no N from 2n
3. Starting at the LSB , copying down each bit upto & including the first 1 bit
encountered , and complimenting the remaining bits.
Ex: Express -45 in 8 bit 2‘s comp form
2n = 100000000
Subtract 45= -00101101
+1
__ _
III method:
bits 11010011
Ex:
R S PATHAK
-73.75 in 12 bit 2‘compform
I method
01001001.1100
10110110.0011
+1
10110110.0100 is 2‘s
II method:
28 = 100000000.0000
Sub 73.75=-01001001.1100
10110110.0100
2’s compliment Arithmetic:
The 2‘s comp system is used to rep –ve no.s using modulus arithmetic . The word length
of a computer is fixed. i.e, if a 4 bit no. is added to another 4 bit no . the result will be
only of 4 bits. Carry if any , from the fourth bit will overflow called the Modulus
arithmetic.
Ex:1100+1111=1011
In the 2‘s compl subtraction, add the 2‘s comp of the subtrahend to the minuend . If there
is a carry out , ignore it , look at the sign bit I,e, MSB of the sum term .If the MSB is a
0, the result is positive.& it is in true binary form. If the MSB is a ` ( carry in or no carry
at all) the result is negative.& is in its 2‘s comp form. Take its 2‘s comp to find its
magnitude in binary.
+46 = 00101110
-14 =+11110010 2‘s comp form of -14
R S PATHAK
-32 (1)00100000 ignore carry
Ignore carry , The MSB is 0 . so the result is +ve. & is in normal binary
form. So the result is +00100000=+32.
+75 = 01001011
-75 =10110101 2‘s comp
+26 = 00011010
-75 2‘s comp form of -75
=+10110101
No carry , MSB is a 1, result is _ve & is in 2‘s comp. The magnitude is 2‘s comp of
11001111. i.e, 00110001 = 49. so result is -49
+77.25 = 01001101.0100
-77.25 = 10110010.1011
1’s compliment arithmetic:
In 1‘s comp subtraction, add the 1‘s comp of the subtrahend to the minuend. If there is a
carryout , bring the carry around & add it to the LSB called the end around carry. Look at the
sign bit (MSB) . If this is a 0, the result is +ve & is in true binary. If the MSB is a 1 ( carry or no
carry ), the result is –ve & is in its is comp form .Take its 1‘s comp to get the magnitude inn
binary.
DIGITAL LOGIC DESIGN Page no. 12
R S PATHAK
Ex: Subtract 14 from 25 using 8 bit 1‘s E↓: ADD -25 to +14
25 = 00011001 +14 = 00001110
-45 = 11110001 -25 =+11100110
+1
No carry MSB =1
00001011 result=-ve=-1110
MSB is a 0 so result is +ve (binary )
=+1110
Binary codes
Binary codes are codes which are represented in binary system with modification from the
original ones.
Weighted Binary codes
Non Weighted Codes
Weighted binary codes are those which obey the positional weighting principles, each
position of the number represents a specific weight. The binary counting sequence is
an example.
Reflective Code
A code is said to be reflective when code for 9 is complement for the code for 0, and
R S PATHAK
so is for 8 and 1 codes, 7 and 2, 6 and 3, 5 and 4. Codes 2421, 5211, and excess-3 are
reflective, whereas the 8421 code is not.
Sequential Codes
A code is said to be sequential when two subsequent codes, seen as numbers in binary
representation, differ by one. This greatly aids mathematical manipulation of data. The 8421 and
Excess-3 codes are sequential, whereas the 2421 and 5211 codes are not.
Non weighted codes are codes that are not positionally weighted. That is, each
position within the binary number is not assigned a fixed value. Ex: Excess-3 code
Excess-3 Code
Excess-3 is a non weighted code used to express decimal numbers. The code derives
its name from the fact that each binary code is the corresponding 8421 code plus
0011(3).
Gray Code
The gray code belongs to a class of codes called minimum change codes, in
which only one bit in the code changes when moving from one code to the next. The
Gray code is non-weighted code, as the position of bit does not contain any weight.
The gray code is a reflective digital code which has the special property that any two
subsequent numbers codes differ by only one bit. This is also called a unit- distance
code. In digital Gray code has got a special place.
R S PATHAK
Binary to Gray Conversion
Each decimal digit 0 through 9 is coded by a 4 bit binary no. called natural binary codes.
Because of the 8,4,2,1 weights attached to it. It is a weighted code & also sequential . it is useful
for mathematical operations. The advantage of this code is its case of conversion to & from
decimal. It is less efficient than the pure binary, it require more bits.
Ex: 14→1110 in binary
The disadvantage of the BCD code is that , arithmetic operations are more complex than
they are in pure binary . There are 6 illegal combinations 1010,1011,1100,1101,1110,1111 in
these codes, they are not part of the 8421 BCD code system . The disadvantage of 8421 code is,
the rules of binary addition 8421 no, but only to the individual 4 bit groups.
BCD Addition:
38 0011 1000
No carry , no illegal code .This is the corrected sum
R S PATHAK
(b). 679.6 + 536.8
679.6 = 0110 0111 1001 .0110 in BCD
+536.8 = +0101 0011 0010 .1000 in BCD
___ _________________
1216.4 1011 1010 0110 . 1110 illegal codes
+0110 + 0011 +0110 . + 0110 add 0110 to each
1 2 1 6 . 4
BCD Subtraction:
Performed by subtracting the digits of each 4 bit group of the subtrahend the digits from
the corresponding 4- bit group of the minuend in binary starting from the LSD . if there is no
borrow from the next group , then 610(0110)is subtracted from the difference term of this group.
(a)38-15
23 0010 0011
No borrow, so correct difference.
.(b) 206.7-147.8
R S PATHAK
BCD Subtraction using 9’s & 10’s compliment methods:
Form the 9‘s & 10‘s compliment of the decimal subtrahend & encode that no. in
the 8421 code . the resulting BCD no.s are then added.
305.5 = 305.5
-168.8= +83.1 9‘s comp of -168.8
_ _
(1)136.6
+1 end around carry
136.7 corrected difference
305.510 = 0011 0000 0101 . 0101
+831.110 = +1000 0011 0001 . 0001 9‘s comp of 1
_ _ _ ________________ _
68.8 in BCD
+1011 0011 0110 . 0110 1011 is illegal code
+0110 add 0110
Excess-3 Addition:
Add the xs-3 no.s by adding the 4 bit groups in each column starting from the LSD. If
there is no carry starting from the addition of any of the 4-bit groups , subtract 0011 from the
sum term of those groups ( because when 2 decimal digits are added in xs-3 & there is no carry ,
result in xs-6). If there is a carry out, add 0011 to the sum term of those groups( because when
there is a carry, the invalid states are skipped and the result is normal binary).
DIGITAL LOGIC DESIGN Page no. 17
R S PATHAK
EX: 37 0110 1010
+28 +0101 1011
_ _ _ _ _ _ _ _ _ _
Subtract the xs-3 no.s by subtracting each 4 bit group of the subtrahend from the
corresponding 4 bit group of the minuend starting form the LSD .if there is no borrow from the
next 4-bit group add 0011 to the difference term of such groups (because when decimal digits are
subtracted in xs-3 & there is no borrow , result is normal binary). I f there is a borrow , subtract
0011 from the differenceterm(b coz taking a borrow is equivalent to adding six invalid states ,
result is in xs-6)
Ex: 267-175
R S PATHAK
Xs-3 subtraction using 9’s & 10’s compliment methods:
Subtraction is performed by the 9‘s compliment or 10‘s compliment
Ex:687-348 The subtrahend (348) xs -3 code & its compliment are:
687 687
-348 → +651 9‘s compl of 348
339 (1)338
+1 end around carry
_
R S PATHAK
The Gray code (reflective –code):
Gray code is a non-weighted code & is not suitable for arithmetic operations. It is not a
BCD code . It is a cyclic code because successive code words in this code differ in one bit
position only i.e, it is a unit distance code.Popular of the unit distance code.It is also a reflective
code i.e,both reflective & unit distance. The n least significant bits for 2 n through 2n+1-1 are the
mirror images of thosr for 0 through 2n-1.An N bit gray code can be obtained by reflecting an N-
1 bit code about an axis at the end of the code, & putting the MSB of 0 above the axis & the
MSB of 1 below the axis.
Reflection of gray codes:
Gray Code
1 bit 2 bit 3 bit 4 bit Decimal 4 bit binary
0 00 000 0000 0 0000
1 01 001 0001 1 0001
11 011 0011 2 0010
10 010 0010 3 0011
110 0110 4 0100
111 0111 5 0101
101 0101 6 0110
110 0100 7 0111
1100 8 1000
1101 9 1001
1111 10 1010
1110 11 1011
1010 12 1100
1011 13 1101
1001 14 1110
1000 15 1111
R S PATHAK
Binary codes block diagram
Error – Detecting codes: When binary data is transmitted & processed,it is susceptible to noise
that can alter or distort its contents. The 1‘s may get changed to 0‘s & 1‘s .because digital
systems must be accurate to the digit, error can pose a problem. Several schemes have been
devised to detect the occurrence of a single bit error in a binary word, so that whenever such an
error occurs the concerned binary word can be corrected & retransmitted.
Parity: The simplest techniques for detecting errors is that of adding an extra bit known as parity
bit to each word being transmitted.Two types of parity: Oddparity, evenparity forodd parity, the
parity bit is set to a ‗0‘ or a ‗1‘ at the transmitter such that the total no. of 1 bit in the word
including the parity bit is an odd no.For even parity, the parity bit is set to a ‗0‘ or a ‗1‘ at the
transmitter such that the parity bit is an even no.
R S PATHAK
When the digit data is received . a parity checking circuit generates an error signal if the
total no of 1‘s is even in an odd parity system or odd in an even parity system. This parity check
can always detect a single bit error but cannot detect 2 or more errors with in the same word.Odd
parity is used more often than even parity does not detect the situation. →here all 0‘s are created
by a short ckt or some other fault condition.
Ans:
(a) No. of 1‘s in the word is even is 6 so word has error
(b) No. of 1‘s in the word is even is 4 so word has error
(c) No. of 1‘s in the word is odd is 5 so there is no error
Checksums:
Simple parity can‘t detect two errors within the same word. To overcome this, use a sort
of 2 dimensional parity. As each word is transmitted, it is added to the sum of the previously
transmitted words, and the sum retained at the transmitter end. At the end of transmission, the
sum called the check sum. Up to that time sent to the receiver. The receiver can check its sum
with the transmitted sum. If the two sums are the same, then no errors were detected at the
receiver end. If there is an error, the receiving location can ask for retransmission of the entire
data, used in teleprocessing systems.
Block parity:
Block of data shown is create the row & column parity bits for the data using odd parity.
The parity bit 0 or 1 is added column wise & row wise such that the total no. of 1‘s in each
column & row including the data bits & parity bit is odd as
R S PATHAK
Data Parity bit data
10110 0 10110
10001 1 10001
10101 0 10101
00010 0 00010
11000 1 11000
00000 1 00000
11010 0 11010
A code is said to be an error –correcting code, if the code word can always be deduced
from an erroneous word. For a code to be a single bit error correcting code, the minimum
distance of that code must be three. The minimum distance of that code is the smallest no. of bits
by which any two code words must differ. A code with minimum distance of 3 can‘t only correct
single bit errors but also detect ( can‘t correct) two bit errors, The key to error correction is that
it must be possible to detect & locate erroneous that it must be possible to detect & locate
erroneous digits. If the location of an error has been determined. Then by complementing the
erroneous digit, the message can be corrected , error correcting , code is the Hamming code , In
this , to each group of m information or message or data bits, K parity checking bits denoted by
P1,P2, --------- pk located at positions 2 k-1 from left are added to form an (m+k) bit code word.
To correct the error, k parity checks are performed on selected digits of each code word, & the
position of the error bit is located by forming an error word, & the error bit is then
complemented. The k bit error word is generated by putting a 0 or a 1 in the 2 k-1th position
depending upon whether the check for parity involving the parity bit P k is satisfied or not.Error
positions & their corresponding values :
R S PATHAK
Error Position For 15 bit code For 12 bit code For 7 bit code
C4 C3 C2 C1 C4 C3 C2 C1 C3 C2 C1
0 0000 0000 000
1 0001 0001 001
2 0010 0010 010
3 0011 0011 011
4 0100 0100 100
5 0101 0101 101
6 0 1 10 0 1 10 1 10
7 0 1 1 1 0 1 1 1 1 1 1
8 1 0 0 0 1 0 0 0
9 1 0 0 1 1 0 0 1
10 1 0 1 0 1 0 1 0
11 1 0 1 1 1 0 1 1
12 1 1 0 0 1 1 0 0
13 1 1 0 1
14 1 1 1 0
15 1 1 1 1
R S PATHAK
Ex: Encode the data bits 1101 into the 7 bit even parity Hamming Code
The bit pattern is
P1P2D3P4D5D6D7
1 1 0 1
12-Bit Hamming Code:It transmit 8 data bits, 4 parity bits located at position 2 0 21 22 23
Word format is
P1 P2 D3 P4 D5 D6 D7 P8 D9 D10 D11 D12
Alphanumeric Codes:
These codes are used to encode the characteristics of alphabet in addition to the decimal
digits. It is used for transmitting data between computers & its I/O device such as printers,
keyboards & video display terminals.Popular modern alphanumeric codes are ASCII code &
EBCDIC code.
R S PATHAK
Digital Logic Gates
Boolean functions are expressed in terms of AND, OR, and NOT operations, it is easier to
implement a Boolean function with these type of gates.
R S PATHAK