Professional Documents
Culture Documents
Data Representation: Professor Dr. Md. Fokhray Hossain Drfokhray@daffodilvarsity - Edu.bd
Data Representation: Professor Dr. Md. Fokhray Hossain Drfokhray@daffodilvarsity - Edu.bd
• Floating Point:
• Character:
– ASCII
– EBCDIC
– Unicode
• Boolean:
08/13/20 "Data Representation" by Dr. Md. Fo 4
khray Hossain
Integers
Decimal Binary
1 00000001
4 00000100
9 00001001
-1 11111111
-4 11111100
-9 11110111
Using Integers: The simplest numbers to consider are the integers. The
positive integer numbers are called unsigned. And the integer numbers that
can also be negative are called signed.
13 = 1 × 101 + 3 × 100
Carry Sum
x y c s
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
(b) Truth Table for half adder
x s
y
c
(c) Circuit
x s
HA
y c
(d) Graphical symbol
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
s i = xi + yi + ci
xi yi
ci 00 01 11 10
0 1
1 1 1 1
ci +1 = xi yi + xi ci + yi ci
(b) Karnaugh maps
08/13/20 "Data Representation" by Dr. Md. Fo 15
khray Hossain
Addition of Unsigned Number
xi
yi si
ci
ci+1
ci si
xi
yi
ci+1
sn-1 s1 s0
MSB position LSB position
Figure: An n-bit ripple carry adder
1’s complement
2’s complement
0111 +7 +7 +7
0110 +6 +6 +6
0001 +1 +1 +1
0000 +0 +0 +0
1000 -0 -7 -8
1111 -7 -0 -1
(EBCDIC).
• UNICODE
… .......................
Value
• Binary Codes
– Meaning of a sequence of binary bits (e.g., 11001111)
• unsigned integer, character, floating-point number, part of a bi
nary program, part of a video or audio stream, etc.
– Interpreting binary bits as an unsigned number
• radix r numbers (radix-10, radix-2, radix-16, etc.)
– qp-1 qp-2 ... q0 . q-1 q-2 ... q-n = i=-np-1 qi * ri
• need to practice fast conversions: decimal, hex, binary
– Signed numbers
• 1’s complement: negative -> invert every bit
• 2’s complement: negative -> invert every bit, add 1 to “lsb”
00 1 1 1
(2 )
01 1 1 1 1
11 1
10 1 I m p le m e n t
u s in g 2 - in p u t
N A N D g a te s
F = CD + A’B + A’C + A’D o n ly .
(1) (2) (3) (4)
C C
D D
A' A'
B B
F I m p le m e n t F
A' A'
u s in g
C C
N AN D
A' g a te s A'
D o n ly D
1 AB' AB 1 4 5 7 6
A B ' + A B = A (B ' + B )
= A * 1
= A CD
AB 00 01 11 10
00 0 1 3 2
E x am p le : 01 4 5 7 6
F = (1 , 4 , 5 , 8 , 9 , 1 2 , 1 3 , 1 4 , 1 5 )
11 12 13 15 14
10 8 9 11 10
08/13/20 "Data Representation" by Dr. Md. Fo 33
khray Hossain
U s in g 0 ' s : U s in g D o n ' t C a r e s ::
CD (3 ) BC
AB 00 01 11 10 A 00 01 11 10
(1 )
00 0 1 1 1 0 1 1 F ( A , B , C ) = ( 0 , 1 , 7 ) w it h d ( 5 )
F = A 'B ' + A C
01 1 1 1 1 1 x 1 (1 ) (2 )
11 0 0 1 0 (2 )
10 0 0 1 0 V a r ia b le - e n t e r e d K - m a p s :
(2) (2) BC
A (1 )
(3 ) (1 ) 00 01 11 10
F ' = A C ' + A D ' + B 'C 'D ' 0 1 1 0
(1 ) (2 ) (3) 0
F = A 'C + A B 'D + A B C D '
T h u s, F = (A ' + C ) (A ' + D ) (B + C + D ) (1 ) (2 ) (3)
1 D D D ' 0
(2) (3 )
A + B C + D E 'F A
A B
B C
C
D
D E'
E' F
F
B
C
D
E'
F
sel
0 I1 x I1
1 I0 O ut f = x' : x' I0 O ut f = x 'y ' + x y :
sel sel
x y
2 - 4 D ec oder
x I1 O 3
y O 2
I0 f = x 'y ' + x y :
O 1
O 0
a c t iv e L O W o u t p u t s