# IEEE754 standard for Real Number

**Learn how real number converted into binary using ieee754 standard**

IEEE754 standard is used to represent a real number into binary. This standard has two different modes.

- Single Precision (32 bits)
- Double Precision (64 bits)

IEEE 754 Single Precision standard is used for storing floating number. Real number is stored in the form of exponent and mantissa.

for example in decimal number system 34234235684790 can be represented as 3.4234235684790 X 10^{13}

value = 34234235684790 = 3.4234235684790 X 10^{13}Exponent = 13 Mantissa = 3.4234235684790

### Conversion of real number into binary

To answer this question you should know how real number is converted into binary. In single precision 0-22 bits(green color) are used to store mantissa, 23-30 bits(blue color) used to store exponent and 31^{th} bit(in red color) used to store sign of the number.

### Step 1 Set sign bit

First step is to check whether real number is negative or positive. Right most bit is used to store sign information.If number is positive then sign bit will be 0 and in case of negative it will be 1.

Example: -12.234

Number is negative number that's why sign bit will be 1.

### Step 2 Convert number into binary form

Above number is having two part one is before decimal and one is after decimal. Before decimal value will be converted into binary using following process.

### Step 3 Normalising binary form

Normalisation shift position of '.', so that before '.' there should be only one digit which must be 1.

Converted binary is

12.234 = 1100.00111010001

To normalise this number '.' will be shifted three position to left side.

Before Normalization 12.234 = 1100.00111010001 After Normalization 12.234 = 1.10000111010001 x 2^{3}

### Step 4 Exponent Calculation

In IEEE754 8 bits are reserved for exponent. 8 bits can store total 256 values. Then range will be [0,1,2 .... 254,255]. Exponent can be negative or positive all values need to be stored in 8 bits.

**Important**There is bias in exponent that's why you have to add 127 in exponent. Exponent is 3 in above example. after adding 127 resultant exponent is 130.

In this range 127 will be considered as 0. Before 127 all values considered as negative and after 127 all values considered as positive.

### Step 5Store calculated exponent in 23-30 bits

Once exponent is calculated then it is converted into binary and stored in 23-30 bits.

1 | 1 | 0 | 0 | 0 | 0 | 0 | 1 | 0 |

### Step 6 Store mantissa part in 0-22 bits

Mantissa part will take binary that appears after '.'. That is "10000111010001"

12.234 = 1.10000111010001 x 2^{3}mantissa=10000111010001

Since mantissa has 23 bits, so during conversion of decimal part of number into binary, 23 digit need to be generated.