0% found this document useful (0 votes)
53 views34 pages

Fixed and Floating Point Numbers: Dr. Ashish GUPTA Sense, Vit-Ap Ashish - Gupta@vitap - Ac.in

Here are the step-by-step workings: 1) (-16.2)8 = -1 * 2^8 2) Biased exponent = 8 + 127 = 135 = 10000111 3) Sign bit = 1 (for negative number) 4) Mantissa = 1 (leading bit is always 1) The 32-bit hexadecimal representation is: C0000000 The closest decimal value is -2.0. The answer is D.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
53 views34 pages

Fixed and Floating Point Numbers: Dr. Ashish GUPTA Sense, Vit-Ap Ashish - Gupta@vitap - Ac.in

Here are the step-by-step workings: 1) (-16.2)8 = -1 * 2^8 2) Biased exponent = 8 + 127 = 135 = 10000111 3) Sign bit = 1 (for negative number) 4) Mantissa = 1 (leading bit is always 1) The 32-bit hexadecimal representation is: C0000000 The closest decimal value is -2.0. The answer is D.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 34

Fixed and Floating Point Numbers

Dr. Ashish GUPTA


SENSE, VIT-AP
[email protected]
Floating Point Numbers

• In real life we also need to be able to represent numbers with


fractional parts (like: -12.5 & 45.39).

▪ Called Floating Point numbers.


▪ These can be stored in two different formats
▪ IEEE-754 32 bit format and IEEE-754 64 bit format
▪ We will learn the IEEE 32-bit floating point representation.
Floating Point Numbers

• In the decimal system, a decimal point (radix point) separates


the whole numbers from the fractional part
• Examples:
37.25 ( whole = 37, fraction = 25/100)
123.567
10.12345678
Fractional Part – Multiplication Method

Ex 1. Find the binary equivalent of 0.25


Step 1: Multiply the fraction by 2 until the fractional part becomes 0
.25
x2
0.5
x2
1.0

Step 2: Collect the whole parts in forward order. Put


them after the radix point
. .5 .25 .125 .0625
. 0 1
Fractional Part – Multiplication Method
Ex 2. Find the binary equivalent of 0.625
Step 1: Multiply the fraction by 2 until the fractional part becomes 0
.625
x 2
1.25
x 2
0.50
x 2
1.0
Step 2: Collect the whole parts in forward order. Put them after the
radix point
. .5 .25 .125 .0625
. 1 0 1
IEEE 32 BIT SINGLE PRECESION FLOTING POINT REPRESENTATION

1 bit
sign 8 bits exponent 23 bits mantissa
1 2 910
32
IEEE Floating Point Representation

• The first (leftmost) field of our floating point


representation will STILL be the sign bit:

• 0 for a positive number,


• 1 for a negative number.
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 biased 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

So what is the range of the exponent that can be represented in 8 bit biased exponent field ???
+128 to -127
Try It Yourself

How would the following exponents be


stored (8-bits, 127-biased):

2-10

28
(Answers on next slide)
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 significand or 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
- 32 Result: -.12500 Result:
8 101000 .03125 .00101
- 8 -.03125
0 .0

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
Find the IEEE FP representation of 40.15625

40.1562510 = 101000.001012

101000.00101 = 1.0100000101 x 25

127 + 5 = 132
13210 = 100001002

1 bit
sign 8 bits exponent 23 bits mantissa
1 2 9 10
32
0 10000100 01000001010000000000000
Decimal Floating Point to IEEE standard Conversion

Ex 2: 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
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
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 steps 1-3

Sign Exponent mantissa


110000011 1000110..0
IEEE standard to Decimal Floating Point Conversion

• Do the steps in reverse order

• In reversing the normalization step move the


radix point the number of digits equal to the
exponent:
• If exponent is positive, move to the right
• If exponent is negative, move to the left
IEEE standard to Decimal Floating Point Conversion

Ex 1: Convert the following 32-bit binary number to its


decimal floating point equivalent:

Sign Exponent Mantissa

1 01111101 010.00
IEEE standard to Decimal Floating Point Conversion

Step 1: Extract the biased exponent and unbias


it

Biased exponent = 011111012 = 12510

Unbiased Exponent: 125 – 127 = -2


IEEE standard to Decimal Floating Point Conversion..

Step 2: Write Normalized number in the form:

Exponent
s Mantissa x 2
(-1) 1 . ____________ ----

For our number:


-1. 01 x 2 –2
IEEE standard to Decimal Floating Point Conversion.

Step 3: Denormalize the binary number from step 2


(i.e. move the decimal and get rid of (x 2n) part):
-0.01012 (negative exponent – move left)

Step 4: Convert binary number to the FP equivalent


(i.e. Add all column values with 1s in them)

-0.01012 = - ( 0.25 + 0.0625)

= -0.312510
IEEE standard to Decimal Floating Point Conversion.

Ex 2: Convert the following 32 bit binary


number to its decimal floating point
equivalent:

Sign Exponent Mantissa


0 10000011 10011000..0

1.10011 x 2 4
IEEE standard to Decimal Floating Point Conversion..

Step 1: Extract the biased exponent and unbias


it

Biased exponent = 10000112 = 13110

Unbiased Exponent: 131 – 127 = 4


IEEE standard to Decimal Floating Point Conversion..

Step 2: Write Normalized number in the form:


Exponent
1 . ____________
Mantissa x 2 ----

For our number:


1.10011 x 2 4
IEEE standard to Decimal Floating Point Conversion.

Step 3: Denormalize the binary number from step 2


(i.e. move the decimal and get rid of (x 2n) part:
11001.12 (positive exponent – move right)

Step 4: Convert binary number to the FP equivalent


(i.e. Add all column values with 1s in them)
11001.1 = 16 + 8 + 1 +.5

= 25.510
Examples
Express following number X= (-16.2)8 in 32 bit IEEE
hexadecimal notation
In IEEE floating point representation, the hexadecimal number
C0000000 corresponds to
(A) -3.0
(B) -1.0
(C) -4.0
(D) -2.0

You might also like