Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 27

Data Representation

Prepared by:
Dr. Anju Sharma
SMCA
CONTENTS
• Data Types

• Complements

• Fixed Point Representation

• Floating Point Representation


Data Representation in Digital
System OR Data Types
• Numbers used in arithmetic computations
• Letters of the alphabet used in data
processing (ASCII Code)
• Other symbols used for specific purpose
Number Systems

• Base or Radix r system : uses distinct


symbols for r digits
• Most common number system :Decimal,
Binary, Octal, Hexadecimal
• Positional-value(weight) System : r2 r1r0.r-1
r-2 r-3
• Multiply each digit by an integer power of r
and then form the sum of all weighted
digits
Number Systems – Decimal

• Base 10
– Ten digits, 0-9
– Columns represent (from right to left) units, tens,
hundreds etc.
123

1102 + 2101 + 3100


or
1 hundred, 2 tens and 3 units
Each position is a power of 10
3052 = 3 x 103 + 0 x 102 + 5 x 101 + 2 x 100
Bases

The base of a number is often indicated by a


subscript. E.g. (123)10 indicates the base-10
number 123.
Binary
• Base 2
– Two digits, 0 & 1
– Columns represent (from right to left) units,
twos, fours, eights etc.

1111011

126 + 125 + 124 + 123 + 022 + 121 + 120


= 164 + 132 + 116 + 18 + 04 + 12 + 11
= 123
Decimal to Binary Conversion

Example – Converting (123)10 into binary


123  2 = 61 remainder 1 Least significant bit (rightmost)
61  2 = 30 remainder 1
30  2 = 15 remainder 0
15  2 = 7 remainder 1
72 = 3 remainder 1
32 = 1 remainder 1
12 = 0 remainder 1 Most significant bit (leftmost)

Read the result upward to give an answer of

(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

7161 + 11160 = 123


Decimal to Hex Conversion

Converting (123)10 into hex

123  16 = 7 remainder 11 (or B)


7  16 = 0 remainder 7

Answer : (123)10 = (7B)16


Binary to Hex / Hex to Binary

Each group of four binary bits maps on to a single hex


digit.
0111 1011

7B
• Even very long numbers can be converted easily, treating
each hex digit independently.

E.g. 1011 1001 0110 1111 1010

B96FA
COMPLEMENTS

Adding to 1 to the r’-1 complement


Finding Two’s Complement
• Step 1: First complement all the bits
(that is find one’s complement)
– Make all 1s as 0s and all 0s as 1s

• Step 2:Then perform increment by 1

– 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.

You might also like