Introduction To Data Representation
Introduction To Data Representation
Programming
CS F111
BITS Pilani
Dubai Campus
BITS Pilani
Dubai Campus
Data Representation
Computer Programs
• Algorithms + Data Structures = Programs
• Book by Nicolas Wirth (Turning Award winner)
(43)10 = (101011)2
(101011)2 = 1x25 + 0x24 + 1x23 + 0x22 + 1x21 + 1x20
= 32 + 0- + 8 + 0 + 2 + 1
= (43)10
• -ve no => ??
0 0 0 1 0 0 0 1 0 0 0 1 0 1 1 0
Carry 0 0 0 1 0 0 0 0 0
(+17) 0 0 0 1 0 0 0 1
+ (+22) 0 0 0 1 0 1 1 0
(+39) 0 0 1 0 0 1 1 1
-17 1 1 1 0 1 1 1 1
Carry 1 1 1 1 1 0 0 0 0
'(+24) 0 0 0 1 1 0 0 0 • Add 2 bits (columnwise)
• Propagate carry (if any) to
+ (-17) 1 1 1 0 1 1 1 1
next column
(+7) 0 0 0 0 0 1 1 1 • Ignore carry from MSB (if any)