CAO 2 Unit 1
CAO 2 Unit 1
CAO 2 Unit 1
NUMBER SYSTEM
Binary Representation of Decimal Number
0 0 10 1010
1 1 11 1011
2 10 12 1100
3 11 13 1101
4 100 14 1110
5 101 15 1111
6 110 16 10000
7 111 17 10001
8 1000 18 10010
9 1001 19 10011
Binary to decimal conversion
Example 1: Convert (111)2 to Decimal.
Solution: We have (111)2 in binary
⇒ 1 ⨯ 22 + 1 ⨯ 2 1 + 1 ⨯ 2 0
=4+2+1=7
●
Example 4: Convert (1010)2 to Decimal.
●
Solution: We have (1010)2 in Binary
●
⇒ 1 ⨯ 23 + 0 ⨯ 22 + 1 ⨯21 + 0 ⨯ 20
●
⇒ 8 + 0 + 2 + 0 = 10
●
Example 5: Convert (10101101)2 to Decimal.
●
Solution: We have (10101101)2 in Binary
●
⇒ 1 ⨯ 27 + 0 ⨯ 26 + 1 ⨯25 + 0 ⨯ 24 + 1 ⨯ 23 + 1 ⨯ 22 + 0 ⨯21 + 1 ⨯ 20
●
= (173)10
Binary to decimal conversion
●
Find the equivalent of (1101)2 in base- 10 ?
●
(1101)2 = (1×23+1×22+0×21+1×20)10
●
=(1×8+1×4+0×2+1×1)10
●
=(8+4+0+1)10
●
=(13)10
Binary to decimal conversion
Find the equivalent of (0.1101)2 in base -10
●
(0.1101)2
●
= (1×2-1+1×2−2+0×2−3+1×2−4)10
●
= (0.5+0.25+0+0.0625)10
●
= (0.8125)10
●
Binary to decimal conversion
●
Find the equivalent of (1101.1101)2 in base- 10
●
Solution :
●
(1101)2=(13)10
●
(0.1101)2=(0.8125)10
●
Hence
●
(1101.1101)2=(13.8125)10
Decimal to Binary Representation of Real Numbers
●
(1011.0011)2
●
= ((1×23+0×22+1×21+1×20)+(0×2-1+0×2-2+1×2-3+1×2-4))10
●
= ((1×8+0×4+1×2+1×1)+(0×0.5+0×0.25+1×0.125+1×0.0625))10
●
= (8+0+2+1+0+0+0.125+0.0625)10
●
= (11.1875)10
Representation of Binary Numbers:
Unsigned Integer
●
Unsigned integers represent positive numbers
●
The decimal range of unsigned 8- bit binary number is 0-255.
●
Unsigned numbers don’t have any sign, these can contain only magnitude of the number. So,
representation of unsigned binary numbers are all positive numbers only.
Unsigned Binary
●
Example-1: Represent decimal number 92 in unsigned binary number.
●
Simply convert it into Binary number, it contains only magnitude of the given number.
●
= (92)10
●
= (1x26+0x25+1x24+1x23+1x22+0x21+0x20)10
●
= (1011100)2
●
It’s 7 bit binary magnitude of the decimal number 92.
Signed Integers
●
In real life we also need to be represent signed numbers (like : -12, -45, +78) .
●
A signed number must have a sign(+/-).
●
Signed numbers contain sign flag, this representation distinguish positive and negative numbers.
This technique contains both sign bit and magnitude of a number.
●
Sign magnitude for 8 bits numbers range from +127 to -127.
●
Two signed number representation methods are :
○
Sign / magnitude representation
○
One’s Complement form
○
Two’s-complement representation
magnitude representation
●
For example,
●
-31 (i.e., 1 11111)
●
+31 (i.e., 0 11111).
●
And zero (0) has two representation,
●
-0 (i.e., 1 00000)
●
+0 (i.e., 0 00000).
e’s Complement Representation
●
For example,
●
-31 (i.e., 1 00000) = 1 11111 = 1 00000
●
+31 (i.e., 0 11111)
●
And zero (0) has two representation,
●
-0 (i.e., 1 11111) = 1 00000 = 1 11111
●
+0 (i.e., 0 00000)
o’s-complement representation
●
And zero (0) has two representation,
-0 (i.e., 1 00000) = 1 00000 = 1 11111+1 = 1 100000 = 1 00000
●
+0 (i.e., 0 00000)
●
Data Representation
●
Fixed Point Representation
●
Floating point Representation
FIXED POINT REPRESENTATION
Fixed Point Representation
Fixed point number actually symbolizes the real data types.
●
It has a fixed number of bits for the integral and fractional parts.
●
As radix point is fixed , the number system is fixed point number system.
●
There are three parts of the fixed-point number representation: Sign bit, Integral part, and Fractional part.
●
Fixed point numbers are those which have a defined
●
numbers after and before the decimal point.
Fixed Point Representation
●
Sign bit:- The negative number has a sign bit 1, while a positive number has a bit 0.
●
Integral Part:- The integral part in fixed-point numbers is of different lengths at different places. It
depends on the register's size; for an 8-bit register, the integral part is 4 bits.
●
Fractional part:- The Fractional part is of different lengths at different places. It depends on the
registers size; for an 8-bit register, the fractional part is 3 bits.
Fixed Point Representation
Size of Sign Bit, Integer Part, and Fractional Part for different registers are displayed b
●
(00010.110)2 = 1 * 21 + 0 * 20 + 1 * 2-1 + 1 * 2-2
●
= 2 + 0.5 + 0.25
●
= (2.75)10
Example :
●
Q. Arithmetic Fixed Point, Compute 0.75 + (-0.625)10 Using Fixed point numbers.
●
Step 1 : 0.75 = (0000.1100)2
●
Step 2 : -0.625 = (0000.1010)2
●
2’s comp. (1111.0110)2
●
Step 3 : 0000.1100
+1111.0110
○
10000.0010
One will
Be
discarded.
Continue....
Fixed Point representation
●
Example −Assume number is using 32-bit format which reserve 1 bit for the sign, 15 bits for the integer
part and 16 bits for the fractional part.
●
Then, -43.625 is represented as following:
●
Where, 0 is used to represent + and 1 is used to represent - . 000000000101011 is 15 bit binary
value for decimal 43 and 1010000000000000 is 16 bit binary value for fractional 0.625.
Problem solving
Problem solving
Problem solving
FLOATING POINT REPRESENTATION
1. To convert the floating point into decimal, we have 3 elements
in a 32-bit floating point representation:
i) Sign
ii) Exponent
iii) Mantissa
●
Sign Bit : Sign bit is the first bit of the binary representation. ‘1’ implies negative number and ‘0’
implies positive number.
●
Example: 11000001110100000000000000000000 This is negative number.
●
Exponent is decided by the next 8 bits of binary representation. 127 is the unique number for 32 bit
floating point representation. It is known as bias. It is determined by 2k-1 -1 where ‘k’ is the number
of bits in exponent field.
●
There are 3 exponent bits in 8-bit representation and 8 exponent bits in 32-bit representation.
●
Thus
●
bias = 127 for 32 bit conversion.
●
Example: 01000001110100000000000000000000
●
10000011 = (131)10
●
131-127 = 4
●
Hence the exponent of 2 will be 4 i.e. 24 = 16.
●
Mantissa is calculated from the remaining 23 bits of the binary representation. It consists of ‘1’ and a
fractional part which is determined by:
●
Example:
●
01000001110100000000000000000000
●
The fractional part of mantissa is given by:
●
1*(1/2) + 0*(1/4) + 1*(1/8) + 0*(1/16) +……… = 0.625
●
Thus the mantissa will be 1 + 0.625 = 1.625
●
The decimal number hence given as: Sign*Exponent*Mantissa = (-1)0*(16)*(1.625) = 26
Fixed Point Vs Floating Point
ERROR AND ITS TYPE
Error
Error – Noise can be introduce the error in the binary bits. It means ‘0’ may change to ‘1’ and ‘1’
●
medium.
●
The external noise can change bits from 1 to 0 or 0 to 1. This change in values changes the meaning of
the actual message and is called an error.
●
For efficient data transfer, there should be error detection and correction codes.
●
An error detection code is a binary code that detects digital errors during transmission.
●
To detect errors in the received message, we add some extra bits to the actual data.
●
Without the addition of redundant bits, it is not possible to detect errors in the received message.
Error detection code methods
●
There are 3 ways in which we can detect errors in the received message :
●
1. Parity Bit
●
2. Two dimension parity check
●
2. Check Sum
Method 1 : PARITY BIT
Parity Bit
Parity bit : A parity bit is an extra bit that is added to the message bits on the sender side.
●
The parity bit is added to the message bits on the sender side, to help in error detection at the receiver side.
●
Even parity
○
Odd parity
○
Two types of Parity system
Even parity : Total number of 1’s in the given data bit should be even. So if the total number of 1’s in
●
the data bit is odd then a single 1 will be appended to make total number of 1’s even else 0 will be
appended(if total number of 1’s are already even).
●
Odd Parity : Total number of 1’s in the given data bit should be odd. So if the total number of 1’s in the
data bit is even then a single 1 will be appended to make total number of 1’s odd else 0 will be
appended(if total number of 1’s are already even).
Method 2 : TWO DIMENSIONAL PARITY
CHECK
Two dimension parity check
●
In this the data word is organized in table (rows and columns).
●
Two-dimensional Parity check bits are calculated for each row and each column, which is equivalent
to a simple parity check bit.
●
then both are sent along with the data. At the receiving end, these are compared with the parity bits
calculated on the received data.
Example :
●
step 1 : all 8-bit data arrange in rows and column
●
step 2 : then find the parity of every row and eve
●
step 3 : then the whole table is send to the receiv
●
step 4 : again we check parity of every column a
Note : It checks and detect upto 3 errors. Error effecting 4 bits may not be detected.
Method 3 : CHECKSUM FOR ERROR
DETECTION
Checksum For Error Detection
●
In this each word is added to the previous word and total sum [Checksum]
●
is calculated.
●
Then the checksum is transmitted along with the data.
●
Idea of checksum => (7, 11, 12, 0, 6) these are the numbers to be send.
●
W1 + w2 + w3 + w4 + w5 => checksum
●
7 + 11 + 12 + 0 + 6 = 36
Data cs Data cs
(transmitter) (receiver)