Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert 32-bit binary number to floating point number?

I have this 32-bit binary number (00111111010000000000000000000000) and I want to know how I can go about converting it to a floating point number.

Without using programming or a converter, how can I manually convert this 32-bit binary number into a floating point number?

Thanks,

Dan

like image 534
Supertecnoboff Avatar asked Sep 18 '25 03:09

Supertecnoboff


1 Answers

Assuming you are a looking for a single floating point here is the format:

First digit is sign, next 8 are the exponent and finally, the last 23 are the significand.

For your number (00111111010000000000000000000000)

Sign: 0 is +
Exponent: 01111110 is -1 (126-127)
Significand: 10000000000000000000000 is 1.5 (The 'invisible' first bit gives you 1, then the second bit (only one set) is 0.5, the next one would have been 0.25, then 0.125 and so on)

You then calculate the value as such:

sign * 2^exp * Significand

1 * 2^-1 * 1.5
1 * 0.5 * 1.5
0.75

You floating point number is equal to 0.75.

like image 88
Pierre-Luc Avatar answered Sep 20 '25 08:09

Pierre-Luc