UNIT 1 Notes
UNIT 1 Notes
Number System
Data Representation
The decimal system is also called the base-10 system because it has 10
discrete numerals or symbols (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) so its base or radix is
10. Decimal Examples: 3.1410, 5210, 12.0310
A binary numbers system has 2 discrete numbers (0, 1) so its base or radix is
2.
An octal numbers system has 8 discrete numbers (0, 1, 2, 3, 4, 5, 6, 7) so its
base or radix is 8.
A hexa-decimal numbers system has 16 discrete numbers (0, 1, 2, 3, 4, 5, 6,
7, 8, 9, A, B, C, D, E, F) so its base or radix is 16.
Binary addition
sum carry
0+0 = 0 0
1+0 = 1 0
0+1 = 1 0
1+1 = 0 1
example ↓
110
+101
--------
1011
11011
+ 1111
----------
101010
Binary subtraction
1110
-111
-------
0111
11011
-10110
---------
00101
Binary multiplication
product
↓
0x0=0
1x0=0
0x1=0
1x1=1
example ↓
1010
x101
-------
1010
0000x
+1010xx
-----------
110010
1101
x 11
--------
1101
+1101x
-----------
100111
Binary division
1's complement
011001
↓↓↓↓↓↓
100110
2's complement
0 1 1 0 0 1 ← number
1 0 0 1 1 0 ← 1's complement
+ 1 ← add 1 to 1's complement
------------
1 0 0 1 1 1 ← 2's complement
10111000
↓
01001000
Before using any complement method for subtraction equate the length of
both minuend and subtrahend by attaching zeros.
Solution. (ii) 3 - 7
Solution. (ii) 5 - 7
r's and r-1's complement
Overflow and underflow are both are the errors that occurred in arithmetic
operations due to a shortage of memory space.
When some operation is performed on two n-bit numbers and we get result of
n+1 bits, this is called an overflow occurs. Let us consider the addition of two
4-bit numbers
9 ---> 1 0 0 1
+8 ---> 1 0 0 0
---------------
17 ---> 1 0 0 0 1
Thus, addition of two 4-bits numbers requires 5-bits (n+1 bits) to represent
the sum. What does a computer then do in this scenario? A computer will
discard the most-significant bit (MSB) and keep the rest.
There are various types of digital number representation, for example: Binary,
octal, decimal, and hexadecimal number system etc. But Binary number
system is most relevant and popular for representing numbers in digital
computer system.
There are two major approaches to store real numbers (i.e., numbers with
fractional component) in modern computing. These are (i) Fixed Point
Notation and (ii) Floating Point Notation. whereas floating point number
allows for a varying number of digits after the decimal point.
In fixed point notation, there are a fixed number of digits after the decimal
point. Fixed point representation has a fixed number of bits for the integral
and fractional parts. There are three parts of the fixed-point number
representation: Sign bit, Integral part, and Fractional part. The below figure
depicts it.
Sign bit: The fixed point number representation uses a sign bit. The
negative number has a sign bit 1, while a positive number has a bit 0.
Integral Part: The integral part depends on the register's size; for an 8-bit
register, the integral part is 4 bits.
Fractional part: Fractional part is also of different lengths at different
places. It depends on the register's size, like in an 8-bit register, integral part
is of 3 bits.
o 8 bits = 1 Sign bit + 4 bits (integral) + 3 bits (fractional part)
o 16 bits = 1 Sign bit + 9 bits (integral) + 6 bits (fractional part)
o 32 bits = 1 Sign bit + 15 bits (integral) + 9 bits (fractional part)
If we want to store 4.5
o Step 1: We will convert the number 4.5 to fixed-point notation with the
following format.
Floating Point representation doesn't reserve any specific number of bits for
the integer or fractional parts. But instead, it reserves certain bits for the
mantissa and the exponent.
The floating-point representation has two types of notation:
1. Scientific notation: it uses a x be form. It is further converted into floating-
point representation. For example, Number = 32635
Number in Scientific Notation = 32.625 x 103
Number is binary form = 1101.101 * 2101
2. Normalization notation: It is a special case of scientific notation.
Normalized means that we have at least one non-zero digit after the decimal
point.
A floating-point representation has three parts: Sign bit, Exponent Part,
and Mantissa. We can see the below diagram to understand these parts.
Sign bit: A negative number has a sign bit 1, while a positive number has a
sign bit 0. The sign of any number depends on mantissa, not on exponent.
Mantissa Part: The mantissa part is of different lengths at different places.
It depends on registers like for a 16-bit register, and mantissa part is of 8
bits.
Exponent Part: It is the power of the number. It depends on the size of the
register. For example, in the 16-bit register, the exponent part is of 7 bits.
How to write numbers in Floating-point notation
o Let the number is 53.5
step 1: We will convert the number 53.5 to binary form 53.5 =110101.1
step 2: Normalize the number (base 2) = (1.101011)*25.
step 3: Represent the binary number in floating-point notation with the
following format.
ASCII Code
Seven bits gives 27 = 128 code words. The numerals and the upper and
lowercase letters add up to 62 characters, leaving 66 7-bit binary strings
available for other words.
Gray Code
Example 1
1 0 1 1=1(1^0)(0^1)(1^1)
=1 1 1 0
(1011)2 = (1110)gray
Example 2
11001 = 1 ( 1 ^ 1 ) ( 1 ^ 0 ) ( 0 ^ 0 ) ( 0 ^ 1)
= 10101
Excess-3 code
A decimal code that has been used in some old computers is the excess-3
code. This is an unweighted code.
It is obtained from the corresponding value of BCD after the addition of 3.
In BCD codes, individual decimal digits are coded in binary notation. Thus
binary codes representing 0 to 9 decimal digits are allowed.
Therefore, all BCD codes have atleast four bits (∵ min. no. of bits required to
encode to decimal digits = 4)
For example, decimal 364 in BCD
3 → 0011
6 → 0110
4 → 0100
364 → 0011 0110 0100
Decimal 643
Add 3 to each 3 3 3
Sum → 976
Converting the sum into BCD code we have 9 7 6
↓ ↓ ↓
1001 0111 0110
BCD Addition
In many application it is required to add two BCD numbers. But the adder
circuits used are simple binary adders, which does not take care of
peculiarity of BCD representation. Thus we must verify the result for valid
BCD by using following rules:
1. If the sum is less then or equal to 9, it is valid BCD number.
2. If sum is greater than 9, it is invalid. Add 6 (0110) to the sum, to make it
valid.
3. If a carry is generated when 6 is added, attach this carry at MSB.
Example 1. Add the following BCD numbers. (i) 1000 and 0101 (ii)
00011001 and 00011000
Solution. (i)
1000 → 8
+0101 →+5
----------- -----
1 1 0 1 13
Solution. (ii)
1 ← ← ← Carry generated
0 0 0 1 1 0 0 1 → 19
0 0 0 1 1 0 0 0 → +18
----------------- ----
0 0 1 1 0 0 0 1 37
Since, a carry is generated we must add 6 (0110) to it.
It ensures that message including parity bit must contain even number of 1's.
It ensures that message including parity bit must contain odd 1's.
Hamming code
How many parity bit can 'm' number of bit message can have?
Now we will see where to place the parity bits within the message.
Let the code is of 7 bits.
There is a rule: the parity bits can always be place at position 2n where n =
0, 1, 2, 3, ...
What will be the value of parity bits?
Example question:
Encode the binary word 1011 into seven bit even parity hamming code.
Assume that the even parity hamming code 0110011 is transmitted & that
0100011 is recevied. The receiver does not know what was transmitted,
determine the error location.
i. (652)10 = ( )2
ii. (25.32)8 = ( )10
iii. (6864)10 = ( )16
iv. (1011)2 = ( )8
v. (5D2)16 = ( )8
vi. (011010110)2 = ( )8
vii. (155)8 = ( )2
viii. (10101.01)2 = ( )10
ix. (BF4A)16 = ( )8
x. (6FBC)16 = ( )8
xi. (1010)2 = ( )2 = ( )10
xii. (72.45)10 = ( )2 = ( )16
xiii. (EFF2.F)16 = ( )8 = ( )10
xiv. (100101.1101)2 = ( )8 = ( )10
xv. (2341)5 = ( )10 = ( )16
Perform the following operation using 2's complement method:
1. (-29)10 + (35)10
2. (-33)10 + (-67)10
1. Encode data bits 0101 into a 7 bit even parity Hamming code.
2. A 7 bit Hamming code is received as 01011101. Check whether it is correct
or not? If it is incorrect, find the correct code.
How is error detection and correction carried out using parity method in
digital data transmission?
Explain grey code and excess-3 code. Encode the following into grey
code and excess-3 code.
1. 45
2. 26
1. 317
2. 89
3. 565
4. 67
What do you mean by r's and r-1's complement? Find out the r's and r-
1's complement of the following numbers:
1. (10011)2
2. (54)10
3. (10101011)2
4. (87)10
References