# Thread: Binary to 32 bit floating point

1. ## Binary to 32 bit floating point

Trying to get to grips with the idea of floating point.
Just looking to convert a binary to float.

The last 8 bits are the exponent.. right?
The most significant bit is on the right?
The first bit is the sign + - ?

If someone could give me an example 32 bit conversion it would spell things out for me.

like this binary for example
11110000 11001100 10101010 00001111

2. 0 100 0010 0101 0101 0110 0110 0010 1010

Okay worked it out a bit more

0 100 0010 0101 0101 0110 0110 0010 1010

The first bit on the left is the sign

0 100 0010 0101 0101 0110 0110 0010 1010

The next 7 are the exponent

0 100 0010 0101 0101 0110 0110 0010 1010

and this is the mantissa

so that means that its a positive number ...with an exponent of 5?? .. not sure how i get five (using java applet to work out the mechanics) ..do I minus 127?

The mantisse is 1.6671803.. which works out as 53.349769592285156 ..not sure how I get here though

The applet I am using is here FloatPointCalculator for reference

3. IEEE floating point 32 standard is:

1 bit for sign
8 bits for exponent, not 7
23 bits for mantissa, not 24

01000010 01010101 01100110 00101010

Sign Bit
Exponent Bits
Mantissa Bits

4. Forgot to mention:

float = (signBit ? -1 : 1)*(2^trueExponent)*(1.mantissa)
Here ^ mean at the power of.

For example 01000010 01010101 01100110 00101010:

Code:
```signBit = 0
biasedExponent = 136 <==> trueExponent = 9
mantissa = 5596714

yourFloat = 1 * 512 * 1.5596714 = 798.5517568```
I wish the example is corrent, i had no time to test it.

5. Just as advice, instead of thinking of "left" and "right" you should think of "most significant" and "least significant." Left and right have nothing to do with anything, other than the way we normally write down binary quantities.

If you turn your computer upside down the meaning of the bits doesn't change even though you've now exchanged left and right.

6. knowing its 8 instead of 7 helps a lot sipher.. thats solved it methinks
that calculation makes a lot more sense now

You are quite correct brewbuck, I am familiar already with this idea for integers.. just wasn't sure if it was reverse ordering for floats.. I must say integers are easy in comparison and up until last week I thought floats were similar

7. My example was incorrect.

You must first make the multiplication and then convert it from binary to decimal.

Sorry...

Here is the correction:

Code:
```signBit = 0
exponent = biasedExponent = 136 <==> trueExponent = 9
mantissa = 01010101 01100110 00101010

yourFloat = 1 * (2^9)* 1.010101010110011000101010
= 1010101010.110011000101010 in binary
= 682.26154 in decimal```