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

CS302 Assignment Fall 2024

Uploaded by

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

CS302 Assignment Fall 2024

Uploaded by

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

CS302 Assignment Fall 2024 (BC230211754)

Solution:

32-Bit floating point number is represented as follows.


 1 bit for Sign (S)
 8 bit for Exponent (E)
 23 bit for the Mantisa (M)
Separate the parts
Sign Bit (S) = 1
Exponent (E) = 10001001
Mantissa (M) = 101101010111010111000111
The sign bit determines the number is +ve or -ve.
If the Sign bit is 0 then its +ve.
If the sign bit is 1 then its -ve.
Here the sign bit 1 so the number will be negative.

Now we convert the exponent to decimal to find the actual exponent.


10001001
=1*(27+0) *(26+0) *(25+0)*(24+1)*(23+0)*(22+0)*(21+1)
=128+0+0+0+8+0+0+1
=137
As we know that IEEE754 format uses a bias of 127 for 32-bit floating-point
numbers.
So, we subtract 127 from 137 to know the actual exponent value
137-127=10
The actual exponent is 10
Now we normalize the mantissa and convert it into decimal.
In IEEE754 format the mantissa is assumed to have an implicit leading 1 in
normalizing form so we can write the mantissa as below
1.1011010101101011000111
Now converting this mantissa into decimal
The integer part is 1 for the fractional part we interpret each binary digit after the
decimal point as a negative power of 2.
=1*(2-1+0)*(2-2+1)*(2-3+1)*(2-4+0)*(2-5+1)*(2-6+0)*(2-7+1)*(2-8+0)*(2-9+1) *(2-
10
+1)*(2-11+0)*(2-12+1)*(2-13+0)*(2-14+1)*(2-15+1)*(2-16+1)*(2-17+0)*(2-18+0) *(2-
19
+0)*(2-20+1)*(2-21+1)*(2-22+1)*(2-23+1)
=0.5+0+0.125+0.0625+0+0.0156+0+0.0039+0+0.0009+0.0004+0+0.0001+0+0.000
03+0.00001+0.000007+0+0+0+0+0+0
=0.7109375
So, the mantissa in decimal is
Integer part + fractional part
=1+0.7109375
=1.7109375
Apply the exponent
=1.7109375*210
=1.7109375*1024
=1751.5
By applying the sign:
As we know that the sign bit is 1 the final value will be negative
That is
=-1751.5

You might also like