GATE - DL Number Systems
GATE - DL Number Systems
ELTP-GATE 1 GATE-CSE-16
Digital Logic
ELTP-GATE 2 GATE-CSE-16
Number Systems
&
Data Representation
ELTP-GATE 3 GATE-CSE-16
Introduction
Computer words are composed of bits, thus words can be
represented as binary numbers
ELTP-GATE 4 GATE-CSE-16
Number Systems
1. Positional Notation
N = (an-1an-2 ... a1a0 . a-1a-2 ... a-m)b
where . = radix point
b= radix or base
n = number of integer digits to the left of the radix point
m = number of fractional digits to the right of the radix point
an-1 = most significant digit (MSD)
a-m = least significant digit (LSD)
2. Polynomial Notation (Series Representation)
n −1
N = ∑
i= − m
a ib i
ai=integer in range (0<= ai <=b-1)
ELTP-GATE 5 GATE-CSE-16
Number Systems (Cont’d)
1. Binary numbers
– Digits = {0, 1}
– (11010.11)2 = 1 x 24 + 1 x 23 + 0 x 22 + 1 x 21 + 0 x 20 + 1 x 2-1 + 1 x 2-2
= (26.75)10
– 1 K (kilo) = 210 = 1,024, 1M (mega) = 220 = 1,048,576,
1G (giga) = 230 = 1,073,741,824
2. Octal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7}
– (127.4)8 = 1 x 82 + 2 x 81 + 7 x 80 + 4 x 8-1 = (87.5)10
3. Hexadecimal numbers
– Digits = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F}
– (B65F)16 = 11 x 163 + 6 x 162 + 5 x 161 + 15 x 160 = (46,687)10
ELTP-GATE 6 GATE-CSE-16
Number Systems (Cont’d)
Important Number Systems
ELTP-GATE 7 GATE-CSE-16
Number Systems (Cont’d)
Complement of a digit A
A’=(b-1)-A
ELTP-GATE 8 GATE-CSE-16
Base Conversion
Case I: b1<b2
ELTP-GATE 9 GATE-CSE-16
Base Conversion (1)
1. Series Substitution Method
ELTP-GATE 10 GATE-CSE-16
Base Conversion (2)
Examples 1:
= (26)10
Examples 1:
= (407)10
ELTP-GATE 11 GATE-CSE-16
Base Conversion (3)
2. Radix Divide Method
Examples
(315)10 = (473)8 b1>b2
Case II:
base-b1 arithmetic can be used
8 315 3 LSD
8 39 7
8 4 4 MSD
0
ELTP-GATE 12 GATE-CSE-16
Base Conversion (4)
3. Radix Multiply Method Case II: b1>b2
Examples 1: base-b1 arithmetic can be
(0.479)10 = (0.3651…)8
MSD 3.832 ← 0.479 × 8
used
6.656 ← 0.832 × 8
5.248 ← 0.656 × 8
LSD 1.984 ← 0.248 × 8
…
Examples 2:
(0.479)10 = (0.0111…)2
MSD 0.9580 ← 0.479 × 2
1.9160 ← 0.9580 × 2
1.8320 ← 0.9160 × 2
LSD 1.6640 ← 0.8320 × 2
…
ELTP-GATE 13 GATE-CSE-16
Base Conversion (4)
General Conversion Algorithm
Algorithm 1
ELTP-GATE 14 GATE-CSE-16
Base Conversion (5)
General Conversion Algorithm
Algorithm 2
(b) the radix divide or multiply method with decimal arithmetic to convert
N from base 10 to base b2.
ELTP-GATE 15 GATE-CSE-16
Base Conversion (6)
Example
(18.6)9 = ( ? )11
N10 = 1 × 91 + 8 × 90 + 6 × 9-1
= 9 + 8 + 0.666…
= (17.666…)10
(b) Convert from base 10 to base 11 using radix divide and multiply
method:
. 7.326 ← 0.666 × 11
11 17 6
11 1 1 3.586 ← 0.326 × 11
0 6.446 ← 0.586 × 11
ELTP-GATE 16 GATE-CSE-16
Base Conversion (7)
Algorithm 3
When b2 = b1k
Examples
ELTP-GATE 17 GATE-CSE-16
Q1.
(1217)8 is equivalent to
(A)(1217)16
(B)(028F)16
(C)(2297)10
(D)(0B17)16
ELTP-GATE 18 GATE-CSE-16
Q2.
ELTP-GATE 19 GATE-CSE-16
Q3.
The hexadecimal representation of 6578 is:
(A)19B2
(B)D782
(C)D712
(D)32F3
ELTP-GATE 20 GATE-CSE-16
Q4.
Given √(224)r = (13)r The value of the radix r is:
(A)10
(B)8
(C)5
(D) 6
ELTP-GATE 21 GATE-CSE-16
Q5.
Let r denote number system radix. The only value(s) of
r satisfy the equation √(121)r =(11)r is/are
(A)decimal 10
(B)decimal 11
(C)Decimal 10 & 11
(D) any value>2
ELTP-GATE 22 GATE-CSE-16
Q6.
If 73x (in base x number system) is equal to 54y (in base y number
system), the possible values of x and y are
(A)8,16
(B)10,12
(C)9,13
(D) 8,11
ELTP-GATE 23 GATE-CSE-16
Number Representation
ELTP-GATE 24 GATE-CSE-16
Negative Number Representation
Options
– Sign-magnitude
– One’s Complement
– Two’s Complement
ELTP-GATE 25 GATE-CSE-16
Sign and Magnitude Representation
9 Computer programs calculate both positive & negative numbers and thus the number
representation has to distinguish both
9 In sign and magnitude representation, a single bit is designated either on the left or
the right of the number to indicate its sign
Example:
ELTP-GATE 26 GATE-CSE-16
Sign-magnitude
Problem +0 000
+3 011
-3 111
-2 110
-1 101
-0 100
ELTP-GATE 27 GATE-CSE-16
One’s Complement (Diminished radix complements)
-3 100
-2 101
-1 110
-0 111
ELTP-GATE 28 GATE-CSE-16
Two’s Complement Representation
q Negative numbers would always have a one in the most significant bit
Æ easy to be tested by hardware
ELTP-GATE 29 GATE-CSE-16
Two’s Complement (Radix complements)
+1 001
100 -1 111
011 -2 110
Add 1
+3 011
100
-3 101
-4 100
ELTP-GATE 30 GATE-CSE-16
Quick negation for Two's Complement
Method 1:
• Convert every 1Æ0 and every 0Æ1 and then add 1 to the rest
Method 2:
•Move from right to left leave every leading 0's until reaching the first 1
•Convert every 0Æ1 and 1Æ0 afterward until reaching the right end
Example: Negate (2)10
(2) 10 = (0000 0000 0000 0000 0000 0000 0000 0010)2
ELTP-GATE 31 GATE-CSE-16
Range of Numbers
An N-bit number
N
– Unsigned: 0 .. (2 -1)
N-1 N-1
– Signed: -2 .. (2 -1)
Example: 4-bit
0000 (0) Unsigned numbers 1111 (15)
ELTP-GATE 32 GATE-CSE-16
Schematic representation of 4-bit 2’s-complement code for
integers in [–8, +7].
ELTP-GATE 33 GATE-CSE-16
Sign extension
When loading numbers in a wide register, the empty bits will be filled with the
value of the sign bit
ELTP-GATE 34 GATE-CSE-16
Computer Arithmetic
ELTP-GATE 35 GATE-CSE-16
Unsigned Arithmetic (Addition) without overflow
010001 (17=16+1)
101011 (43=32+8+2+1)
--------------------------------
111100 (60=32+16+8+4)
ELTP-GATE 36 GATE-CSE-16
Unsigned Arithmetic (Addition) with overflow
Unsigned arithmetic
101111 (47)
The carry is 011111 (31)
Not discarded ---------------
1001110 (78) Due to overflow, note that
78 cannot be represented
by a 6-bit unsigned number)
ELTP-GATE 37 GATE-CSE-16
Signed Arithmetic (Addition) without overflow
ELTP-GATE 38 GATE-CSE-16
Add : 4 Combinations
9 (-9)
Negative / Positive
Positive / Positive + 5 + 5
14 -4
9 (-9)
Positive / Negative + (-5) Negative / Negative + (-5)
4 - 14
ELTP-GATE 39 GATE-CSE-16
Sub : 4 Combinations
9 (-9)
Positive / Positive - 5 Negative / Positive - 5
4 - 14
9 (-9)
Positive / Negative - (-5) Negative / Negative - (-5)
14 - 4
ELTP-GATE 40 GATE-CSE-16
Compare Signed Number
ELTP-GATE 41 GATE-CSE-16
Compare Signed Number
ELTP-GATE 42 GATE-CSE-16
Binary Code
Type of code
N=w4x4+w3x3+w2x2+w1x1
ELTP-GATE 43 GATE-CSE-16
Binary Code
Type of code
ELTP-GATE 44 GATE-CSE-16
Binary Code (Non-weighted Code)
Cyclic code => In which all successive codeword differ in
only one digit
Example : Gray code (reflected code)
Decimal Binary Gray Code Decimal Binary Gray code
0 0000 0000 8 1000 1100
1 0001 0001 9 1001 1101
2 0010 0011 10 1010 1111
3 0011 0010 11 1011 1110
4 0100 0110 12 1100 1010
5 0101 0111 13 1101 1011
6 0110 0101 14 1110 1001
7 0111 0100 15 1111 1000
ELTP-GATE 45 GATE-CSE-16
Self complement code
ELTP-GATE 46 GATE-CSE-16
Binary-to-Gray Code Conversion
Retain most significant bit.
From left to right, add each adjacent pair of binary code
bits to get the next Gray code bit, discarding carries.
1 0 1 + 1 0 Binary 1 0 1 1 + 0 Binary
↓ ↓
1 1 1 0 Gray 1 1 1 0 1 Gray
(10110)2 = (11101)Gray
ELTP-GATE 47 GATE-CSE-16
Gray-to-Binary Conversion
Retain most significant bit.
From left to right, add each binary code bit generated to the Gray code
bit in the next position, discarding carries.
1 1 0 1 1 Gray 1 1 0 1 1 Gray
+ ↓ + ↓
1 0 0 1 Binary 1 0 0 1 0 Binary
(11011)Gray = (10010)2
ELTP-GATE 48 GATE-CSE-16
Q7.
Addition of three base 4 numbers “321” ,“122” and “111”
results is ________
a)1210
b)1220
c)1211
d)220
ELTP-GATE 49 GATE-CSE-16
Q8.
Addition of two octal numbers “36” and “71” results in
________
a)213
b)123
c)127
d)345
ELTP-GATE 50 GATE-CSE-16
Q9.
The decimal “17” in BCD will be represented as _________
a)11101
b)11011
c)10111
d)11110
ELTP-GATE 51 GATE-CSE-16
Q10.
Consider the number given by the decimal expression:
163 * 9 + 162 * 7 + 16 * 5 + 3
The number of 1’s in the unsigned binary representation of
the number is ___________.
a)7
b)9
c)8
d)6
ELTP-GATE 52 GATE-CSE-16
Q11.
The number of 1’s in the binary representation of
(3*4096+15*256+5*16+3) are:
(A)8
(B) 9
(C)10
(D)12
ELTP-GATE 53 GATE-CSE-16
Q12.
The octal representation of an integer is (342)8, if this were to
be treated as an eight-bit signed integer, in computer system,
its decimal equivalent is:
(A)226
(B)-98
(C) 76
(D) -30
ELTP-GATE 54 GATE-CSE-16
Q13.
Ans: D
ELTP-GATE 55 GATE-CSE-16
Q14.
Ans: B
ELTP-GATE 56 GATE-CSE-16