How to Convert a Decimal Number to a Binary Single-precision Floating Point Number

In order to convert a decimal number to a binary single-precision floating point number, first of all, we need to convert the decimal number to its binary equivalent (unsigned magnitude form). A proper sign should be added based on the sign of the decimal number. But remember, we should not perform the signed representation. Then we need to follow the steps discussed in single-precision floating point representation article.

To understand the conversion clearly, we will take an example in this article.

Example: Represent 3462.5 in IEEE 754 single-precision floating point format.

Solution: First of all, we will convert the decimal number to its equivalent binary number.

3462.5 = 110110000110.1

We can write, 110110000110.1 = 1.101100001101 x 211

So, the three parts of the floating point number are as below:

Sign (S) = 0, as the number is positive

Extended Exponent (E) = 11+127 = 138

So, the exponent in binary form is 10001010.

Mantissa (F): 101100001101

We will pad additional zeros to the right of the mantissa to make it 23 bits in the final representation.

The complete floating-point number is as below:

Example of Decimal to IEEE 754 single-precision binary floating point number conversion

Previous           Table of Content           Next

Leave a Reply

Your email address will not be published. Required fields are marked *