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

CS302 Assignment 1

fall 2024 Assignment

Uploaded by

dilawaizramzan89
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CS302 Assignment 1

fall 2024 Assignment

Uploaded by

dilawaizramzan89
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

CS302

Assignment: 01

Question No 01:

Convert the following 32-Bit Binary Floating-Point Number into a Decimal Number.

11000100110110101011010111000111

32-bit of floating point number is represented as follows:

1 bit for the sign (S)

8 bits for the exponent (E)

23 bits for the mantissa (fraction) (M)

Separate the Parts:

Sign bit (S) = 1

Exponent (E) = 10001001

Mantissa (M) = 10110101011010111000111

The sign bit determines if the number is positive or negative:

 If the sign bit is 0, the number is positive.


 If the sign bit is 1 , the number is negative.

Here’s the sign bit is 1, so the number will be negative.

Convert the Exponent to Decimal and Find the Actual Exponent:

100010012

1*27 +¿ 0*26 +¿ 0*25 +¿0*24 + ¿1*23 +¿0*22 +¿0*21 +¿1*20

128+8+1 =137

100010012 =13710

Calculate the unbiased exponent: IEEE 754 format uses a bias of 127 for 32-bit floating-point numbers. So,
subtract 127 from the exponent we just calculated:

137-127=10

The actual exponent is 10


Normalize the Mantissa and Convert to Decimal:

11000100110110101011010111000111

In IEEE 754 format, the mantissa (or fraction) is assumed to have an implicit leading 1 in normalize form. So, we
can write the mantissa as:

11000100110110101011010111000111

Convert 1.1000100110110101011010111000111 to decimal

The integer part is 1

For the fractional part 10110101011010111000111, we interpret each binary digit after the decimal point as a
negative power of 2:

−1 −2 −3 −4 −5 −6 −7 −8 −9 −1 0
1∗2 + 0∗2 + 1∗2 +1∗2 + ¿ 0∗2 +1∗2 +0∗2 +1∗2 +0∗2 +1∗2 +¿
−1 1 −12 −1 3 −1 4 −15 −1 6
1∗2 + 0∗2 +1∗2 + 0∗2 +1∗2 +1∗2 +¿
−1 7 −1 8 −1 9 −20 −2 1 −22 −23
1∗2 + 0∗2 + 0∗2 + 0∗2 +1∗2 +1∗2 +¿ 1∗2
0.5+0+0.125+0.0625+0+0.0156+0+0.0039+0+0.0009+0.0004+0+0.0001+0+0.00003+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

Apply the Sign:

Since the sign bit was 1, the final value is negative:

-1751.5

So the final answer is:

11000100110110101011010111000111

-1751.5

You might also like