73.2k views
5 votes
Convert +41.50 in a IEEE 754 single precision format.

Convert - 72.125 in a IEEE 754 double precision format.

1 Answer

2 votes

Answer:

+41.50 = 0 10000100 01001100000000000000000 [single precision]

-72.125 = 1 10000000101 0010000010000000000000000000000000000000000000000000 [double precision]

Step-by-step explanation:

(I) +41.50 using single precision

Follow the following steps:

(a) Single precision has 32 bits in total and is divided into three groups: sign (has 1 bit), an exponent (has 8 bits) and a mantissa (also called fraction, has 23 bits)

(b) Divide the number (41.50) into its whole and decimal parts:

Whole = 41

Decimal = 0.50

(c) Convert the whole part to binary:

2 | 41

2 | 20 r 1

2 | 10 r 0

2 | 5 r 0

2 | 2 r 1

2 | 1 r 0

| 0 r 1

Reading upwards gives 41 = 101001₂

(d) Convert the decimal part to binary:

0.50 x 2 = 1.0 = 1 [number in front of decimal]

0.0 x 2 = 0.0 = 0 [number in front of decimal]

Reading downwards gives 0.5 = 10₂

(e) Put the two parts together as follows;

101001.10₂

(f) Convert the result in (e) to its base 2 scientific notation:

Move the decimal to just before the leftmost bit as follows;

1.0100110

In doing so, we have moved over 5 numbers to the left. Therefore, the exponent is 5. Moving to the left gives a positive exponent while moving to the right gives a negative exponent.

Altogether we have;

1.0100110 x 2⁵

(g) Determine the sign bit of the number and display in binary: Since the number +41.50 is positive, the sign bit is 0.

(h) Determine the exponent bits.

Since this is a single precision conversion, the exponent bias is 127.

To get the exponent we add the exponent value from (e) to the exponent bias and get;

5 + 127 = 132

(i) Convert the exponent to binary:

2 | 132

2 | 66 r 0

2 | 33 r 0

2 | 16 r 1

2 | 8 r 0

2 | 4 r 0

2 | 2 r 0

2 | 1 r 0

| 0 r 1

Reading upwards gives 132 = 10000100₂

(j) Determine the mantissa bits:

The mantissa is the rest of the number after the decimal of the base 2 scientific notation found in (f) above.

0100110 from 1.0100110 x 2⁵ [Just remove the leftmost 1 and the decimal point]

(k) Combine the three parts: sign bit (1 bit), exponent bits (8 bits) and mantissa bits (23 bits)

sign bit = 0 [1 bit]

exponent bits = 10000100 [8 bits]

mantissa bits = 0100110 [7 out of 23 bits]

Then fill out the remaining part of the mantissa with zeros to make it 23 bits.

mantissa bits = 01001100000000000000000

Putting all together we have

0 10000100 01001100000000000000000 as +41.50 in a IEEE 754 single precision format.

(II) -72.125 using double precision

Follow the following steps:

(a) Double precision has 32 bits in total and is divided into three groups: sign (has 1 bit), an exponent (has 11 bits) and a mantissa (also called fraction, has 52 bits)

(b) Divide the number (72.125) into its whole and decimal parts:

Whole = 72

Decimal = 0.125

(c) Convert the whole part to binary:

2 | 72

2 | 36 r 0

2 | 18 r 0

2 | 9 r 0

2 | 4 r 1

2 | 2 r 0

2 | 1 r 0

| 0 r 1

Reading upwards gives 72 = 1001000₂

(d) Convert the decimal part to binary:

0.125 x 2 = 0.25 = 0 [number in front of decimal]

0.25 x 2 = 0.50 = 0 [number in front of decimal]

0.50 x 2 = 1.00 = 1 [number in front of decimal]

0.00 x 2 = 0.00 = 0 [number in front of decimal]

Reading downwards gives 0.125 = 0010₂

(e) Put the two parts together as follows;

1001000.0010₂

(f) Convert the result in (e) to its base 2 scientific notation:

Move the decimal to just before the leftmost bit as follows;

1.0010000010

In doing so, we have moved over 6 numbers to the left. Therefore, the exponent is 6. Moving to the left gives a positive exponent while moving to the right gives a negative exponent.

Altogether we have;

1.0010000010 x 2⁶

(g) Determine the sign bit of the number and display in binary: Since the number -72.125 is negative, the sign bit is 1.

(h) Determine the exponent bits.

Since this is a double precision conversion, the exponent bias is 1023.

To get the exponent we add the exponent value from (e) to the exponent bias and get;

6 + 1023 = 1029

(i) Convert the exponent to binary:

2 | 1029

2 | 514 r 1

2 | 257 r 0

2 | 128 r 1

2 | 64 r 0

2 | 32 r 0

2 | 16 r 0

2 | 8 r 0

2 | 4 r 0

2 | 2 r 0

2 | 1 r 0

| 0 r 1

Reading upwards gives 1029 = 10000000101₂

(j) Determine the mantissa bits:

The mantissa is the rest of the number after the decimal of the base 2 scientific notation found in (f) above.

0010000010 from 1.0010000010 x 2⁶ [Just remove the leftmost 1 and the decimal point]

(k) Combine the three parts: sign bit (1 bit), exponent bits (11 bits) and mantissa bits (52 bits)

sign bit = 1 [1 bit]

exponent bits = 10000000101 [11 bits]

mantissa bits = 0010000010 [10 out of 52 bits]

Then fill out the remaining part of the mantissa with zeros to make it 52 bits.

mantissa bits = 0010000010000000000000000000000000000000000000000000

Putting all together we have

1 10000000101 0010000010000000000000000000000000000000000000000000 as -72.125 in a IEEE 754 double precision format.

User Anyany Pan
by
6.7k points