Professional Documents
Culture Documents
DC Unit 1
DC Unit 1
NUMBER SYSTEM: Binary Number Representations – Signed Numbers and Complements, Unsigned, Fixed point
and Floating point numbers. Addition and Subtraction with 1’s and 2’s complements. CODES: Binary code for
decimal numbers – Gray code – Codes for detecting and correcting errors: Even and Odd parity codes, Hamming
Codes, Checksum codes, m-out-of-n codes.
UNIT 1
NUMBER SYSTEMS
Introduction to Digital System
In digital system, the data is usually in binary states (0 and 1) and is processed and stored
electronically to prevent errors due to noise and interfering signals.
The term digital in digital circuits is derived from the way circuit perform operations by
counting digits.
A digital circuit operates with binary numbers, i.e only in two states. The output of the
circuit is either low (0) or high (1) in a positive logic system.
In general 0 represents zero volts and 1 represents five volts. If the situation is reverse, it is
known as negative logic system.
Digital circuits find application in computers, telephony, data processing, radar navigation,
military systems, etc.
The advantages of digital systems are as follows:
Digital systems are generally easier to design.
Digital information storage is easy.
Accuracy and precision are greater as compared to the analog system.
Digital circuits are less affected by noise.
More digital circuitry can be fabricated on IC chips.
Number Systems
Number system is a basis for counting various items. On hearing the word number all of us
immediately think of the familiar decimal number system with its 10 digits, i.e. 0, 1,
2,3,4,5,6,7,8 and 9.
Modern computers communicate and operate with binary numbers which use only the
digits 0 and 1.
(0.513)10 = (0.4065)8
2 673
2 336 1
2 168 0
2 84 0
2 42 0
2 21 0
2 10 1
2 5 0
2 2 1
1 0
(673.23)10 = (1010100001.0011)2
The symbols A, B, C, D, E and F represents 10, 11, 12, 13, 14 and 15. Each significant
position in an octal number has positional weight.
The least significant position has weight of 160 , i.e 1; the higher significant position are
given weights in ascending powers of eight, i.e. 161, 162, 163, etc.
Signed numbers are represented with a separate sign bit along with the magnitude. In an 8-
bit number, the MSB is the sign bit and the remaining 7 bit corresponds to the magnitude.
The magnitude part contains true binary equivalent of the number for positive numbers,
while 2’s complement form of the number for negative numbers.
In sign – magnitude form, additional bit called the sign bit is placed in front of the number.
If the sign bit is 0, the number is positive. If it is a 1, the number is negative.
Consider an example 0101001. In this number the LSB (Least Significant Bit) is 0. So it
will be negative number. Therefore the number can be represented as (-41).
Consider an example 1001001. In this number the LSB (Least Significant Bit) is 1. So it
will be positive number. Therefore the number can be represented as (+41).
The unsigned numbers are positive numbers. It can be represented either as a 8 bit number
or with additional bits considering as 0’s.
Format to represent unsigned number is xxxxx --> 000xxxxx,Copy the original integer
into the LSBs, and put 0's elsewhere.
Complements
Complements are used in digital computer for simplifying the subtraction operations and
for logical manipulations.
There are two types of complements for each base r number system. When the value of the
base r is substituted in the name.
Find the 9’s and 10’s Complements for the given decimal number (467)
Solution
To find the 10’s complement of 467, first we have to find the 9’s complement of 467. The 9’s
complement of a number can be found by subtracting each bit by 9.
9’s complement of 467 = 999
-467
= 532
10’s Complement of a number can be found by adding 1 to the 9’s complement of that number.
10’s Complement of 467 = 532
+ 1
10’s Complements of 467 = 533
Complement the decimal value (5976) using 9’s and 10’s complement methods.
Decimal Value = 5976
9’s Complement Method:
9999
Decimal value = 5976
9’s Complement no. = 4023
Find the 1’s and 2’s Complements for the given binary number 10101
To find the 2’s complement of 10101, first we have to find the 1’s complement of 10101. The 1’s
complement of a number can be found by changing 0 to 1 and 1 to 0.
Sign Sign
0 0.6132789 0 04
Mantissa exponent
The mantissa has a 0 in the leftmost position to denote a plus. Here the mantissa is
considered to be a fixed point fraction.
This representation is equivalent to the number expressed as fraction 10 times by an
exponent that is 0.632789 × 10+04. The mantissa is also called the fractional part,
Sign Sign
0 36754 1 03
When the number is represented in a register in its binary coded-form, the actual value of
the register becomes 0 011 110 111 101 100 and 1 000 011.
Most computers and all electronic calculators have a built-in capacity to perform floating
point arithmetic operations.
Addition
Many modern digital computers employ the binary (base-2) number system to represent
numbers, and carry out the arithmetic operations using binary arithmetic.
In performing decimal arithmetic it is necessary to memorize the tables giving the results
of the elementary arithmetic operations for pairs of decimal digits.
Similarly, for binary arithmetic the tables for the elementary operations for the binary
digits are necessary. The binary addition table is as follows:
0+0=0 0+1=1
1+0=1 1 + 1 = 0 (with carry 1)
Add the two numbers (1011101) and (100111)
1 0 1 1 1 0 1
+ 1 0 0 1 1 1
1 0 1 0 1 0 0
BCD addition
Add two 4 bit BCD numbers using ordinary binary addition. If 4 bit sum is
equal to or less than the sum is a valid BCD number and no correction is
needed.
If the 4 bit sum is greater than 9or if a carry is generated from the sum(step1)
the sum is invalid BCD number Then, the digit 6(0110)should be added to the
sum to produce the valid BCD symbols. Examples are given below.
1001+0100
9 1001
4 0100
0110 Add 6
6+3
6 0110 Sum equals 9 or less with carry 0
3 0011
9 1001 Valid BCD for 9
6+8
6 0110
8 1000
14 1110 Invalid BCD number (>9) 1110
0110 Add 6
Code
Code is a symbolic representation of discrete information, which may be present in the
form of numbers, letters or physical quantities. The symbols used are the binary digits 0
and 1 which are arranged according to the rules of codes.
These codes are used communicate information to a digital computer and to retrieve
message from it. A code is used to enable an operator to feed data into a computer
directly, in the form of decimal numbers, alphabets and special characters.
The computer converts the data into binary codes and after computation, transforms the
data into its original format.
When number, letters, or words are represented by a special group of symbols, this is
called encoding, and the group of symbols is called a code.
Codes can be broadly classified as
Weighted Binary Codes
Non-Weighted codes
Error-detecting Codes
Error-Correcting Codes
Alphanumeric Codes
Non-Weighted Code
Excess-3 Code
The excess-3 code is another important BCD code. It is particularly significant for
arithmetic operations as it overcomes the shortcomings encountered while using the 8421
BCD code to add two decimal digits whose sum exceeds 9.
The excess-3 code has no such limitation, and it considerably simplifies arithmetic
operations. The excess-3 code for a given decimal number is determined by adding ‘3’ to
each decimal digit in the given number and then replacing each digit of the newly found
decimal number by its four-bit binary equivalent.
It may be mentioned here that, if the addition of ‘3’ to a digit produces a carry, as is the
case with the digits 7, 8 and 9, that carry should not be taken forward.
The result of addition should be taken as a single entity and subsequently replaced with
its excess-3 code equivalent.
Also, it is normal practice to represent a given decimal digit or number using the
maximum number of digits that the digital system is capable of handling.
Corresponding to a given excess-3 code, the equivalent decimal number can be
determined by first splitting the number into four-bit groups, starting from the radix point,
and then subtracting 0011 from each four-bit group.
The new number is the 8421 BCD equivalent of the givenexcess-3 code, which can
subsequently be converted into the equivalent decimal number.
Another significant feature that makes this code attractive for performing arithmetic
operations is that the complement of the excess-3 code of a given decimal number yields
the excess-3 code for 9’scomplement of the decimal number.
As adding 9’s complement of a decimal number B to a decimal number A achieves A –
B, the excess-3 code can be used effectively for both addition and subtraction of decimal
numbers.
Binary Codes for Decimal Numbers
Gray Code
The Gray code is an un-weighted binary code in which two successive values differ only
by 1 bit.
Owing to this feature, the maximum error that can creep into a system using the binary
Gray code to encode data is much less than the worst-case error encountered in the case
of straight binary encoding.
That is, the last and the first entry also differ by only1 bit. This is known as the cyclic
property of the Gray code.
Although there can be more than one Gray code for a given word length, the term was
first applied to a specific binary code for non-negative integers and called the binary-
reflected Gray code or simply the Gray code.
The gray code belongs to a class of codes called minimum change codes, in which only
one bit in the code group changes when moving from one step to the next.
The gray code is a reflective digital code which has a special property of containing two
adjacent code numbers that differ by only one bit. Therefore it is also called as uni-
distance code, where the bit differs by 1 bit.
Gray Code–Binary Conversion:
A given Gray code number can be converted into its binary equivalent by going through
the following steps:
Begin with the most significant bit (MSB). The MSB of the binary number is the same as
the MSB of the Gray code number.
The bit next to the MSB (the second MSB) in the binary number is obtained by adding the
MSB in the binary number to the second MSB in the Gray code number and disregarding
the carry, if any.
The third MSB in the binary number is obtained by adding the second MSB in the binary
number to the third MSB in the Gray code number. Again, carry, if any, is to be ignored.
The process continues until we obtain the LSB of the binary number.
Convert (110111)G to binary code
Gray code = 1 1 0 1 1 1
1 0 0 1 0 1
(110111)G = (100101)2
Although the number of bits in error being equal to or greater than 4 is a very rare
occurrence, the addition of a single parity cannot be used to detect two-bit errors, which is
a distinct possibility in data storage media such as magnetic tapes.
Secondly, the single-bit parity code cannot be used to localize or identify the error bit
even if one bit is in error. There are several codes that provide self-single-bit error
detection and correction mechanisms.
Checksum Codes
Check-sums and cyclic redundancy checks are used to detect error in the
transmission of block of data.
Check-sum is formed by adding all the data bytes in the block, ignoring any
carries. It is the arithmetic sum of all data bytes. The resulting sum is stored
after the data block.
When the data is read, it is re -added and the sum is compared with the
recorded check-sum. There is no error in the data transmission if both the sum
matches; otherwise data has to be re-transmitted.
Hamming Codes
If we have a sufficient number of redundant bits, and if these bits can be arranged such
that different error bits produce different error results, then it should be possible not only
to detect the error bit but also to identify its location.
In fact, the addition of redundant bits alters the ‘distance’ code parameter, which has
come to be known as the Hamming distance. The Hamming distance is nothing but the
number of bit disagreements between two code words.
For example, the addition of single-bit parity results in a code with a Hamming distance
of at least 2.
The smallest Hamming distance in the case of a threefold repetition code would be 3.
Hamming noticed that an increase in distance enhanced the code’s ability to detect and
correct errors.
Hamming’s code was therefore an attempt at increasing the Hamming distance and at the
same time having as high an information throughput rate as possible.
The message bit to be transmitted is 0110. Find the Hamming code for the given message.
B3B2B1B0 = 0110
h1 = B 3 B 2 B 0 = 0 1 0 = 1
h2 = B 3 B 1 B 0 = 0 1 0 = 1
h4 = B 2 B 1 B 0 = 1 1 0 = 0
h3 = B 3 = 0
h5 = B 2 = 1
h6 = B 1 = 1
h7 = B 0 = 0
The hamming code h1h2h3h4h5h6h7 = 1 1 0 0 1 1 0
m – out of - n codes
m-out-of-n code words with m number of 1‘s in it and remaining all 0‘s. It
is useful to detect unidirectional multiple errors.
In a unidirectional error, all of the erroneous bits change in the same direction
(0s change to 1s, 1s change to 0s).
The total number of valid code words in m-out-of-n code can be given by the
binomial co-efficientwhich has the value
Thus a 2-out-of-4 code has 6 valid code words, and 3-out-of-6 code has
20 valid code words.
OtherCodes.
Alphanumeric Codes:
Alphanumeric codes, also called character codes, are binary codes used to represent
alphanumeric data.
The codes write alphanumeric data, including letters of the alphabet, numbers,
mathematical symbols and punctuation marks, in a form that is understandable and
process-able by a computer.
These codes enable us to interface input–output devices such as keyboards, printers,
VDUs, etc., with the computer.
One of the better-known alphanumeric codes in the early days of evolution of computers,
when punched cards used to be the medium of inputting and outputting data, is the 12-bit
Hollerith code.
The Hollerith code was used in those days to encode alphanumeric data on punched
cards. The code has, however, been rendered obsolete, with the punched card medium
having completely vanished from the scene.
Two widely used alphanumeric codes include the ASCII and the EBCDIC codes. While
the former is popular with microcomputers and is used on nearly all personal computers
and workstations, the latter is mainly used with larger systems.
Traditional character encodings such as ASCII, EBCDIC and their variants have a
limitation interms of the number of characters they can encode.
In fact, no single encoding contains enough characters so as to cover all the languages of
the European Union.
As a result, these encodings do not permit multilingual computer processing. Unicode,
developed jointly by the Unicode Consortium and the International Standards
Organization (ISO), is the most complete character encoding scheme that allows text of
all forms and languages to be encoded for use by computers. Different codes are
described in the following.
ASCII code:
The ASCII (American Standard Code for Information Interchange) is strictly a seven-bit
code based on the English alphabet.
ASCII codes are used to represent alphanumeric data in computers, communications
equipment and other related devices.
Since it is a seven-bit code, it can at the most represent 128 characters. It currently defines
95 printable characters including 26 upper-case letters (A to Z),26 lower-case letters (a to
z), 10 numerals (0 to 9) and 33 special characters including mathematical symbols,
punctuation marks and space character.
In addition, it defines codes for 33 non printing, mostly obsolete control characters that
affect how text is processed.
With the exception of ‘carriage return’ and/or ‘line feed’, all other characters have been
rendered obsolete by modern mark-up languages and communication protocols, the shift
from text-based devices to graphical devices and the elimination of tele-printers, punch
cards and paper tapes.
An eight-bit version of the ASCII code, known as US ASCII-8or ASCII-8, has also been
developed.
The eight-bit version can represent a maximum of 256 characters. That is, numerals 0 to 9
are represented by binary sequences from 0011 0000 to 0011 1001 respectively.
Also, lower-case and upper-case letters differ in bit pattern by a single bit. While upper-
case letters ‘A’ to ‘O’ are represented by 01000001 to 0100 1111, lower-case letters ‘a’ to
‘o’ are represented by 0110 0001 to 0110 1111.
Similarly, while upper-case letters ‘P’ to ‘Z’ are represented by 0101 0000 to 0101 1010,
lower-case letters ‘p’to ‘z’ are represented by 0111 0000 to 0111 1010.
With widespread use of computer technology, many variants of the ASCII code have
evolved over the years to facilitate the expression of non-English languages that use a
Roman-based alphabet.
In some of these variants, all ASCII printable characters are identical to their seven-bit
ASCII code representations.
EBCDIC code:
The EBCDIC (Extended Binary Coded Decimal Interchange Code), is another widely used
alphanumeric code, mainly popular with larger systems. The code was created by IBM to
extend the binary coded decimal that existed at that time.
All IBM mainframe computer peripherals and operating systems use EBCDIC code, and
their operating systems provide ASCII and Unicode modes to allow translation between
different encodings. It may be mentioned here that EBCDIC offers no technical advantage
over the ASCII code.
Its importance in the earlier days lay in the fact that it made it relatively easier to enter data
into larger machines with punch cards.
Since, punch cards are not used on mainframes anymore; the code is used in contemporary
mainframe machines solely for backwards compatibility.
It is an eight-bit code and thus can accommodate up to 256 characters. A single byte in
EBCDIC is divided into two four-bit groups called nibbles.
The first four-bit group, called the ‘zone’, represents the category of the character, while
the second group, called the ‘digit’, identifies the specific character.