Download as pdf or txt
Download as pdf or txt
You are on page 1of 20

DATA REPRESENTATION

NUMERIC AND ALPHANUMERIC


NUMERIC REPRESENTATION
Decimal Digit Representation
• Binary Coded Decimal (BCD)
• Unpacked Decimal Format (Zoned Decimal Format)
• Packed Decimal Format

Binary Digit Representation


• Signed Binary Numbers
- Absolute Value Representation
• Fixed Point
• Floating Point
NUMERIC REPRESENTATION
DECIMAL DIGIT REPRESENTATION

Binary Coded Decimal (BCD)


In BCD, EACH number is defined by a binary code of 4 BITS.
We use digits from 0 to 9 and its binary equivalent to form BCD.
DECIMAL BINARY
0 0000
1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
8 1000
9 1001
EXAMPLE:
896 1000100101102
8 9 6
1000 1001 0110

3724 00110111001001002 DECIMAL BINARY

3 7 2 4 0 0000
0011 0111 0010 0100 1 0001
2 0010
2 1. 0 5 00100001.000001012 3 0011
2 1 . 0 5 4 0100
0010 0001 . 0000 0101 5 0101
6 0110
09.726 1001.0111001001102
7 0111
9 . 7 2 6
8 1000
1001 . 0111 0010 0110
9 1001
NUMERIC REPRESENTATION
DECIMAL DIGIT REPRESENTATION

Unpacked Decimal Format


(Zoned Decimal Format)
Uses 1 byte (8bits) for each digit of the decimal number.
19 11110001 1 byte

Represents the values of 0 to 9 in the least significant 4 bits of 1 byte.


19 11110001 0001

In the most significant 4 bits, called the zoned bits, 1111 is stored.
19 11110001 1111

The 4 bits that represent the sign is stored in the zoned bits of the least
significant digit (Positive and Zero is represented by 1100 while negative
is 1101)
19 11001001 1100 + SIGN
-19 11011001 1101 - SIGN
EXAMPLE:
1028 111100011111000011110010110010002
1 0 2 8
11110001 11110000 11110010 11001000

-724 1111011111110010110101002 DECIMAL BINARY

7 2 4 0 0000
11110111 11110010 11010100 1 0001
2 0010
-593 1111010111111001110100112
3 0011
5 9 3 4 0100
11110101 11111001 11010011 5 0101
6 0110
1. 6 2 11110001.11110110110000102
7 0111
1 . 6 2
8 1000
11110001 11110110 11000010 9 1001
NUMERIC REPRESENTATION
DECIMAL DIGIT REPRESENTATION

Packed Decimal Format


One 1 byte represents 2 digits of the decimal number.
198 0001 1001 1 byte

The least significant 4 bits represents the sign.


For positive and zero (1100)
For negative (1101)
198 1000 1100 1100

Packed Decimal of 198 :


1 9 8 +
0001 1001 1000 1100
EXAMPLE:
1028 0000000100000010100011002
1 0 2 8 +
0000 0001 0000 0010 1000 1100

-724 01110010010011012 DECIMAL BINARY

7 2 4 - 0 0000
0111 0010 0100 1101 1 0001
2 0010
-6593 0000011001011001001111012
3 0011
6 5 9 3 - 4 0100
0000 0110 0101 1001 0011 1101
5 0101
6 0110
162 00010110001011002
1 6 2 + 7 0111
0001 0110 0010 1100 8 1000
9 1001
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

IUnpacked
I I I
P
P
Packed
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

SIGNED BINARY NUMBERS


ABSOLUTE VALUE REPRESENTATION
Uses an 8-bit representation where the first bit corresponds to the sign
and the last seven bits to the value of the number. 0 for positive and 1
for negative.
The Range of Numeric Values that can be represented is only
-127 to 127
EXAMPLE:
-1310 = 100011012
1910 = 000100112
-3210 = 101000002
12710 = 011111112

12810 = 100000002
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

FIXED POINT
A fixed point just means that there are a fixed number of digits after the
decimal point.
Example:
Fixed Point Representation using 4 integer bits and 4 fraction bits:
10.1012 = 0010.10102
Fixed Point Representation using 2 integer bits and 4 fraction bits:
111.012 = 11.01002
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

FLOATING POINT
Used to represent real number data type.
Represents either extremely large or small size data.

Example:
Write 27310 in scientific notation:
• Move the decimal point to the left until you have a number greater
than or equal to 1 and less than 10 and count the number of decimal
places you moved, it represent the exponent of the base/radix.
• 27310 = 2.73 x102
Write 100000.0012 in scientific notation:
• Move the decimal point to the left until you have a number greater
than or equal to 1 and less than 10 and count the number of decimal
places you moved, it represent the exponent of the base/radix.
• 100000.0012 = 1.00000001 x25
FLOATING POINT

M x RE
Decimal
• M = Mantissa 1.101000111 x 109
• R = Radix Binary
• E = Exponent
1.101000111 x 29
Floating Point Representation using 32 bits :
• 1 sign bit
• 8 exponent bits
• 23 bits for the mantissa
1 bit 8 bits 23 bits
SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + Exponent
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
EXAMPLE:
FLOATING POINT

22810
GET THE BINARY EQUIVALENT OF THE DECIMAL NUMBER
AND THEN CONVERT TO SCIENTIFIC NOTATION
22810 = 111001002
= 1.1100100 X 27

+ 127 + 7 1100100
0 10000110 11001000000000000000000

The floating representation for 22810 is


0100 0011 0110 0100 0000 0000 0000 0000

1 bit 8 bits 23 bits


SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + (Exponent)
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
EXAMPLE:
FLOATING POINT

-411.82510
GET THE BINARY EQUIVALENT OF THE DECIMAL NUMBER
AND THEN CONVERT TO SCIENTIFIC NOTATION
- 411.82510 = 110011011.1101002
= 1.10011011110100 X 28

- 127 + 8 10011011110100
1 10000111 10011011110100000000000

The floating representation for -411.82510 is


1100 0011 1100 1101 1110 1000 0000 0000

1 bit 8 bits 23 bits


SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + (Exponent)
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
EXAMPLE:
FLOATING POINT

192.8610
GET THE BINARY EQUIVALENT OF THE DECIMAL NUMBER
AND THEN CONVERT TO SCIENTIFIC NOTATION
192.8610 = 11000000.110111000010100011112
= 1.100000011011100001010001111 X 27

+ 127 + 7 100000011011100001010001111
0 10000110 10000001101110000101000

The floating representation for 192.8610 is


0100 0011 0100 0000 1101 1100 0010 1000

1 bit 8 bits 23 bits


SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + (Exponent)
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
EXAMPLE:
FLOATING POINT

-513.9510
GET THE BINARY EQUIVALENT OF THE DECIMAL NUMBER
AND THEN CONVERT TO SCIENTIFIC NOTATION
-513.9510 = 1000000001.111102
= 1.00000000111110 X 29

- 127 + 9 00000000111110
1 10000001 00000000111110000000000

The floating representation for -513.9510 is


1100 0000 1000 0000 0111 1100 0000 0000

1 bit 8 bits 23 bits


SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + (Exponent)
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
EXAMPLE:
FLOATING POINT

-513.9510
GET THE BINARY EQUIVALENT OF THE DECIMAL NUMBER
AND THEN CONVERT TO SCIENTIFIC NOTATION
-513.9510 = 1000000001.111102
= 1.00000000111110 X 29

- 127 + 9 00000000111110
1 10000001 00000000111110000000000

The floating representation for -513.9510 is


1100 0000 1000 0000 0111 1100 0000 0000

1 bit 8 bits 23 bits


SIGN EXPONENT MANT ISSA
Radix is 2 Get all the bits after the
+=0 decimal point
127 + (Exponent)
- =1
Get the binary Add zeroes ‘till you reach
equivalent 23 bits.
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

EXAMPLE FOR ASCII :


Odd Parity
R
52
0 101 0010
T
54
0 101 0100

Even Parity
u
75
1 111 0101
NUMERIC REPRESENTATION
BINARY DIGIT REPRESENTATION

EXAMPLE FOR EBCDIC: :


Odd Parity

Even Parity

You might also like