Professional Documents
Culture Documents
Data Representation: Prepared By: Dr. Anju Sharma Smca
Data Representation: Prepared By: Dr. Anju Sharma Smca
Prepared by:
Dr. Anju Sharma
SMCA
CONTENTS
• Data Types
• Complements
• Base 10
– Ten digits, 0-9
– Columns represent (from right to left) units, tens,
hundreds etc.
123
1111011
(123)10 = (1111011)2
Hexadecimal
• Base 16
– Sixteen digits, 0-9 and A-F (ten to fifteen)
– Columns represent (from right to left) units,
16s, 256s, 4096s etc.
7B
7B
• Even very long numbers can be converted easily, treating
each hex digit independently.
B96FA
COMPLEMENTS
– Add 0001b
Two’s Complement as -ve
Number
• Two’s complement is -ve number because
binary addition of a n-bit number with it’s
complement gives nbit result with all bits = 0s
Highest Two’s Complement format +
ve Number
• A highest positive arithmetic number is
when at msb there is 0 and all
remaining bits are 1s
Lowest Two’s Complement format
− ve Number
• A lowest negative arithmetic number is
when at msb there is 1 and all
remaining bits are 0s
Arithmetic Numbers
• Two’s complement format arithmetic number
• Maximum 8-bit number = 0111 1111( +127)
• Minimum 8-bit number = 1000 0000 ( −128)
Arithmetic Numbers
• Two’s complement format arithmetic
number
• Maximum 16-bit number
• = 0111 1111 1111 1111( +32767)
• Minimum 16-bit number
• = 1000 0000 0000 0000 ( −32768)
EXAMPLE
• Number +16392 0100 0000 0000 1000
• One’s complement 1011 1111 1111 0111
+ 0000 0000 0000 0001
−163921011 1111 1111 1000
Binary subtraction A − B
• Add A with two’s complement of B to find
A − B, provided we use two’s
complementation for representation − ve
numbers
Example: Find 129 − 128
• 0000 0000 1000 0001 [= +129d]
• 1111 1111 1000 0000 [= − 128d]
• 0000 0000 0000 0001 [= + 1d]
SUMMARY
• Two’s complement is found by first
finding 1’s complement and then adding
0001b.
• Two’s complement gives negative of a
given number
• Adding a number with it’s two’s
complement gives all bits = 0s
Binary Arithmetic - Addition
• Binary long addition works just like
decimal long addition.
1 0 0 1 1 1
+ 0 0 1 1 1 0
0 1 1 1 0 0 Carried digits
1 1 0 1 0 1 Result
OVERFLOW
Floating Point Representation
example
– 0.12 × 0.12 = 0.0144
• would be expressed as
– (1.2 × 10−1) × (1.2 × 10−1) = (1.44 × 10−2).
• In a fixed-point system with the decimal
point at the left, it would be
– 0.120 × 0.120 = 0.014.