0% found this document useful (0 votes)
64 views

Data Representation

1) Data can be represented in binary, with each additional bit doubling the number of possible codes. Common number systems include binary, octal, hexadecimal, and decimal. 2) Common data types include integers, floating point numbers, characters, and Booleans. Floating point numbers represent values that change continuously using a sign, exponent, and mantissa according to the IEEE standard. 3) Character codes like ASCII and EBCDIC assign numeric codes to letters, numbers, and symbols to allow digital representation and processing of text-based data.

Uploaded by

Bidrohi Tollat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
64 views

Data Representation

1) Data can be represented in binary, with each additional bit doubling the number of possible codes. Common number systems include binary, octal, hexadecimal, and decimal. 2) Common data types include integers, floating point numbers, characters, and Booleans. Floating point numbers represent values that change continuously using a sign, exponent, and mantissa according to the IEEE standard. 3) Character codes like ASCII and EBCDIC assign numeric codes to letters, numbers, and symbols to allow digital representation and processing of text-based data.

Uploaded by

Bidrohi Tollat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 28

Data Representation

1
Data Representation
• Binary: The computer numbering system.
1 binary digit allows 2n = 2 codes (0,1)
2 binary digit allows 2n = 4 codes (00,01,10,11)
3 binary digit allows 2n = 8 codes (000,…..111)
…………………………………………………
7 binary digit allows 2n = 128 codes (0000000,…..1111111)
8 binary digit allows 2n = 256 codes (00000000,…..11111111)

ASCII: American Standard Code for Information Interchange


EBCDIC: Extended Binary Coded Decimal Interchange Code

2
Data Representation
• Bit: 0 (Off) or 1 (On).

• Byte: 8 bits can make a byte.

• Word: The word is the computer’s basic unit of


data, the unit concerned in data storage,
processing and transfer.

3
Data Representation
• Integer:

• Floating Point:

• Character:
– ASCII
– EBCDIC
– Unicode

• Boolean:
4
Integers

Decimal Binary
1 00000001
4 00000100
9 00001001
-1 11111111
-4 11111100
-9 11110111

5
Positive Number Representation

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.

For an example the number 13 represents,

13 = 1 × 101 + 3 × 100

6
Positive Number Representation
Conversion between Decimal and Binary systems:
1. For an example the binary number 1101 represents the value
V = 1 × 23 + 1 × 22 + 0 × 21 + 1 × 20
V = 13
Hence, (1101)2 = (13)10

2. The decimal number 13 represents the value


2 13
2 6–1
2 3–0
1–1
Hence, (13)10 = (1101)2
7
Positive Number Representation

Conversion Octal and Hexadecimal Representation:


1. The decimal number 125 represents the octal value
8 125
8 15 – 5
1–7
Hence, (125)10 = (175)8

2. The decimal number 125 represents the Hexadecimal value


16 125
7 – 13
Hence, (125)10 = (7D)16
8
Number in different systems
Decimal Binary Octal Hexadecimal
00 00000 00 00
01 00001 01 01
02 00010 02 02
03 00011 03 03
04 00100 04 04
05 00101 05 05
06 00110 06 06
07 00111 07 07
08 01000 10 08
09 01001 11 09
10 01010 12 0A
11 01011 13 0B
12 01100 14 0C
13 01101 15 0D
14 01110 16 0E
15 01111 17 0F
16 10000 20 10
17 10001 21 11
18 10010 22 12

9
Floating Point

Values that change continuously


Decimals and fractions
<Sign>0.Mantissa *2exponent

Sign Exponent Mantissa

10
Floating Point Representation
• Floating point numbers can be stored into 32-bits, by dividing the bits
into three parts:
the sign, the exponent, and the mantissa.
• the plus/minus sign is represented by one bit, the highest-weighted bit
(furthest to the left)
• the exponent is encoded using 8 bits immediately after the
sign
• the mantissa (the bits after the decimal point) with the
remaining 23 bits

 
11
Floating Point Representation
• The first (leftmost) field of our floating point
representation will be the sign bit:
– 0 for a positive number,
– 1 for a negative number.

12
Storing the Binary Form
How do we store a radix point?
- All we have are zeros and ones…
Make sure that the radix point is ALWAYS in the same
position within the number.
Use the IEEE 32-bit standard
 the leftmost digit must be a 1
Solution is Normalization
Every binary number, except the one corresponding to the
number zero, can be normalized by choosing the exponent
so that the radix point falls to the right of the leftmost 1 bit.

37.2510 = 100101.012 = 1.0010101 x 25

7.62510 = 111.1012 = 1.11101 x 22

0.312510 = 0.01012 = 1.01 x 2-2


IEEE Floating Point Representation
• The second field of the floating point number will be the
exponent.
• The exponent is stored as an unsigned 8-bit number,
RELATIVE to a bias of 127.
– Exponent 5 is stored as (127 + 5) or 132
• 132 = 10000100
– Exponent -5 is stored as (127 + (-5)) or 122
• 122 = 01111010
Try It
How would the following exponents be stored (8-bits,
127-biased):

2-10

28
Answers
2-10
exponent -10 8-bit
bias +127 value
117  01110101
28
exponent 8 8-bit
bias +127 value
135  10000111
IEEE Floating Point Representation

• The mantissa is the set of 0’s and 1’s to the right of the
radix point of the normalized (when the digit to the left
of the radix point is 1) binary number.
Ex: 1.00101 X 23
(The mantissa is 00101)

 The mantissa is stored in a 23 bit field, so we add zeros


to the right side and store:
00101000000000000000000
Decimal Floating Point to
IEEE standard Conversion

 Ex 1: Find the IEEE FP representation of 40.15625

Step 1.
Compute the binary equivalent of the whole part and
the fractional part. (i.e. convert 40 and .15625 to their
binary equivalents)
Decimal Floating Point to
IEEE standard Conversion

  40 .15625
Result: Result:
101000 .00101

So: 40.1562510 = 101000.001012

 
Decimal Floating Point to
IEEE standard Conversion

Step 2. Normalize the number by moving the decimal point


to the right of the leftmost one.

101000.00101 = 1.0100000101 x 25
 
Decimal Floating Point to
IEEE standard Conversion

Step 3. Convert the exponent to a biased exponent

127 + 5 = 132

And convert biased exponent to 8-bit unsigned binary:

13210 = 100001002
 
Decimal Floating Point to
IEEE standard Conversion

Step 4. Store the results from steps 1-3:

Sign Exponent Mantissa


(from step 3) (from step 2)

0 10000100 01000001010000000000000

 
Decimal Floating Point to
IEEE standard Conversion

Ex 2: Find the IEEE FP representation of


–24.75 

 
Decimal Floating Point to
IEEE standard Conversion

Ex : Find the IEEE FP representation of –24.75 


Step 1. Compute the binary equivalent of the whole
part and the fractional part. 
24 .75
- 16 Result: - .50 Result:
8 11000 .25 .11
- 8 - .25
0 .0
  So: -24.7510 = -11000.112
25
Decimal Floating Point to
IEEE standard Conversion

Step 2.
Normalize the number by moving the
decimal point to the right of the leftmost
one.

-11000.11 = -1.100011 x 24

26
Decimal Floating Point to
IEEE standard Conversion

Step 3. Convert the exponent to a biased exponent


127 + 4 = 131
==> 13110 = 100000112
 
Step 4. Store the results from above
Sign Exponent mantissa
1 10000011 1000110..0
27
Character Codes

• The American Standard Code for Information


Interchange (ASCII).

• The Extended Binary Coded Decimal Interchange Code

(EBCDIC).

• UNICODE

28

You might also like