In one of your comments you indicated that the binary number represents a float in 8 byte long IEEE 754 binary64 format. However that is inconsistent with the -0b1110 value you showed as an example, so I've ignored it and used my own which is in the proper format as example input data for testing the answer shown below.

Essentially what is done is first the binary string is converted into an integer value, then next into a string of raw bytes which is passed to struct.unpack() for final conversion to a floating point value. The bin_to_float() function shown below drives the process. Although not illustrated, binary input string arguments can be prefixed with '0b'.

from codecs import decode
import struct


def bin_to_float(b):
    """ Convert binary string to a float. """
    bf = int_to_bytes(int(b, 2), 8)  # 8 bytes needed for IEEE 754 binary64.
    return struct.unpack('>d', bf)[0]


def int_to_bytes(n, length):  # Helper function
    """ Int/long to byte string.

        Python 3.2+ has a built-in int.to_bytes() method that could be used
        instead, but the following works in earlier versions including 2.x.
    """
    return decode('%%0%dx' % (length << 1) % n, 'hex')[-length:]


def float_to_bin(value):  # For testing.
    """ Convert float to 64-bit binary string. """
    [d] = struct.unpack(">Q", struct.pack(">d", value))
    return '{:064b}'.format(d)


if __name__ == '__main__':

    for f in 0.0, 1.0, -14.0, 12.546, 3.141593:
        print('Test value: %f' % f)
        binary = float_to_bin(f)
        print(' float_to_bin: %r' % binary)
        floating_point = bin_to_float(binary)  # Round trip.
        print(' bin_to_float: %f\n' % floating_point)

Output:

Test value: 0.000000
 float_to_bin: '0000000000000000000000000000000000000000000000000000000000000000'
 bin_to_float: 0.000000

Test value: 1.000000
 float_to_bin: '0011111111110000000000000000000000000000000000000000000000000000'
 bin_to_float: 1.000000

Test value: -14.000000
 float_to_bin: '1100000000101100000000000000000000000000000000000000000000000000'
 bin_to_float: -14.000000

Test value: 12.546000
 float_to_bin: '0100000000101001000101111000110101001111110111110011101101100100'
 bin_to_float: 12.546000

Test value: 3.141593
 float_to_bin: '0100000000001001001000011111101110000010110000101011110101111111'
 bin_to_float: 3.141593
Answer from martineau on Stack Overflow
๐ŸŒ
Binary Convert
binaryconvert.com โ€บ convert_float.html
Float (IEEE754 Single precision 32-bit) Converter
Online binary converter. Supports all types of variables, including single and double precision IEEE754 numbers
๐ŸŒ
VisibleEarth
h-schmidt.net โ€บ FloatConverter โ€บ IEEE754.html
IEEE-754 Floating Point Converter
You can either convert a number by choosing its binary representation in the button-bar, the other fields will be updated immediately. Or you can enter a binary number, a hexnumber or the decimal representation into the corresponding textfield and press return to update the other fields. To make it easier to spot eventual rounding errors, the selected float number is displayed after conversion to double precision.
Discussions

python - How to convert a binary (string) into a float value? - Stack Overflow
I want to convert a binary number into a float number. Here's an example of a possibility: >>> float(-0b1110) gives me the correct output: -14.0 Unfortunately, I am working with binary s... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Convert From binary to Float in C
uint32_t temp; float val; temp = (uint32_t)raw_bytes[0]; temp |= (uint32_t)raw_bytes[1] << 8; temp |= (uint32_t)raw_bytes[2] << 16; temp |= (uint32_t)raw_bytes[3] << 24; memcpy(&val, &tmp, sizeof(val)); or you may need to combine them in the reverse order depending on platform/communication protocol endian. More on reddit.com
๐ŸŒ r/C_Programming
18
1
May 3, 2021
Binary to Float?
Hi, Is there a way to easily convert binary to 32 bit IEEE float in Arduino Due? Like for a 16 bit int, I can do something like: num = B1 More on forum.arduino.cc
๐ŸŒ forum.arduino.cc
15
0
January 23, 2015
What's a good way to convert from binary to float?
Open the file using fopen and then read the binary file using fread. Depending on the file, it may need to be opened using the machine format argument. See http://www.mathworks.com/help/matlab/ref/fopen.html Oh, and don't forget to close the file pointer when you're done with fclose. More on reddit.com
๐ŸŒ r/matlab
7
0
August 3, 2015
People also ask

How do I convert a decimal to IEEE 754 binary?
Enter your decimal number in our IEEE 754 converter above. It instantly shows the 32-bit or 64-bit binary representation, along with the hex value and a step-by-step breakdown of the sign, exponent, and mantissa fields.
๐ŸŒ
ieee754calc.com
ieee754calc.com
IEEE 754 Converter โ€” Free Online Floating Point Calculator
How do I convert a number to floating-point?

To convert a decimal number to a floating-point representation, follow these steps:

  1. Convert the entire number to binary and then normalize it, i.e. write it in scientific notation using base 2.
  2. Truncate the fraction after the decimal point to the allowable fraction length.
  3. Extract the sign, exponent, and fraction segments.

Refer to the IEEE754 standard for more detailed instructions.

๐ŸŒ
omnicalculator.com
omnicalculator.com โ€บ other โ€บ floating-point
Floating-Point Calculator
What is the difference between 32-bit and 64-bit floating point?
32-bit (single precision) uses 1 sign bit, 8 exponent bits, and 23 mantissa bits. 64-bit (double precision) uses 1 sign bit, 11 exponent bits, and 52 mantissa bits, giving far greater precision and range.
๐ŸŒ
ieee754calc.com
ieee754calc.com
IEEE 754 Converter โ€” Free Online Floating Point Calculator
๐ŸŒ
Numeral-systems
numeral-systems.com โ€บ ieee-754-converter
IEEE-754 floating point numbers converter
This calculator can be used to convert decimal numbers to a binary floating point number in IEEE-754 format or vice versa.
๐ŸŒ
Exploring Binary
exploringbinary.com โ€บ home โ€บ decimal to floating-point converter
Decimal to Floating-Point Converter - Exploring Binary
June 1, 2018 - A decimal to IEEE 754 binary floating-point converter, which produces correctly rounded single-precision and double-precision conversions.
๐ŸŒ
Baseconvert
baseconvert.com โ€บ ieee-754-floating-point
IEEE 754 Floating Point Converter - Base Convert
Online number base converter for binary, hexadecimal, octal, decimal, roman numerals, balanced ternary, negabinary, factorial, bijective, and any radix. Supports high precision and fractional values.
Top answer
1 of 7
24

In one of your comments you indicated that the binary number represents a float in 8 byte long IEEE 754 binary64 format. However that is inconsistent with the -0b1110 value you showed as an example, so I've ignored it and used my own which is in the proper format as example input data for testing the answer shown below.

Essentially what is done is first the binary string is converted into an integer value, then next into a string of raw bytes which is passed to struct.unpack() for final conversion to a floating point value. The bin_to_float() function shown below drives the process. Although not illustrated, binary input string arguments can be prefixed with '0b'.

from codecs import decode
import struct


def bin_to_float(b):
    """ Convert binary string to a float. """
    bf = int_to_bytes(int(b, 2), 8)  # 8 bytes needed for IEEE 754 binary64.
    return struct.unpack('>d', bf)[0]


def int_to_bytes(n, length):  # Helper function
    """ Int/long to byte string.

        Python 3.2+ has a built-in int.to_bytes() method that could be used
        instead, but the following works in earlier versions including 2.x.
    """
    return decode('%%0%dx' % (length << 1) % n, 'hex')[-length:]


def float_to_bin(value):  # For testing.
    """ Convert float to 64-bit binary string. """
    [d] = struct.unpack(">Q", struct.pack(">d", value))
    return '{:064b}'.format(d)


if __name__ == '__main__':

    for f in 0.0, 1.0, -14.0, 12.546, 3.141593:
        print('Test value: %f' % f)
        binary = float_to_bin(f)
        print(' float_to_bin: %r' % binary)
        floating_point = bin_to_float(binary)  # Round trip.
        print(' bin_to_float: %f\n' % floating_point)

Output:

Test value: 0.000000
 float_to_bin: '0000000000000000000000000000000000000000000000000000000000000000'
 bin_to_float: 0.000000

Test value: 1.000000
 float_to_bin: '0011111111110000000000000000000000000000000000000000000000000000'
 bin_to_float: 1.000000

Test value: -14.000000
 float_to_bin: '1100000000101100000000000000000000000000000000000000000000000000'
 bin_to_float: -14.000000

Test value: 12.546000
 float_to_bin: '0100000000101001000101111000110101001111110111110011101101100100'
 bin_to_float: 12.546000

Test value: 3.141593
 float_to_bin: '0100000000001001001000011111101110000010110000101011110101111111'
 bin_to_float: 3.141593
2 of 7
17

This works for me. Tested with Python3.4:

def float_to_bin(num):
    return bin(struct.unpack('!I', struct.pack('!f', num))[0])[2:].zfill(32)

def bin_to_float(binary):
    return struct.unpack('!f',struct.pack('!I', int(binary, 2)))[0]

float_to_bin(bin_to_float(float_to_bin(123.123))) == float_to_bin(123.123)
>>> True
Find elsewhere
๐ŸŒ
Omni Calculator
omnicalculator.com โ€บ other โ€บ floating-point
Floating-Point Calculator
February 22, 2022 - The floating-point calculator is here to help you understand the IEEE754 standard for the floating-point format. It acts as a converter for floating-point numbers โ€” it converts 32-bit floats and 64-bit floats from binary representations to real decimal numbers and vice versa.
๐ŸŒ
Cornell University
cs.cornell.edu โ€บ ~tomf โ€บ notes โ€บ cps104 โ€บ floating
Floating Point
Say we have the decimal number 329.390625 and we want to represent it using floating point numbers. The method is to first convert it to binary scientific notation, and then use what we know about the representation of floating point numbers to show the 32 bits that will represent it.
๐ŸŒ
IEEE 754 Converter
ieee754calc.com
IEEE 754 Converter โ€” Free Online Floating Point Calculator
The IEEE 754 converter is the most accurate free tool for converting decimal numbers to IEEE 754 floating point format. Whether you need 16-bit Half , 32-bit single precision or 64-bit double precision, our IEEE 754 converter gives you instant ...
๐ŸŒ
Penjee
blog.penjee.com โ€บ binary-numbers-floating-point-conversion
Binary numbers โ€“ floating point conversion | Penjee, Learn to Code
May 3, 2015 - Convert decimal number to binary scientific notation, processing the integral and fractional part independently. The scientific binary number is then normalized (the decimal point is moved to the left most position, adjusting the exponent accordingly) ... The binary floating point number is constructed with all converted number parts.
๐ŸŒ
Arduino Forum
forum.arduino.cc โ€บ projects โ€บ programming
Binary to Float? - Programming - Arduino Forum
January 23, 2015 - Hi, Is there a way to easily convert binary to 32 bit IEEE float in Arduino Due? Like for a 16 bit int, I can do something like: num = B1
๐ŸŒ
Ryan's Tutorials
ryanstutorials.net โ€บ binary-tutorial โ€บ binary-floating-point.php
Binary Fractions and Floating Point - Binary Tutorial
Learn how to convert binary fractions and floating point numbers. An easy to follow yet comprehensive introduction to representing really big and really small numbers in binary.
๐ŸŒ
Reddit
reddit.com โ€บ r/matlab โ€บ what's a good way to convert from binary to float?
r/matlab on Reddit: What's a good way to convert from binary to float?
August 3, 2015 -

I'm trying to read binary data (binary representations of 32 bit float numbers) and convert them to floating point numbers.

What's a good way of doing this? I was looking into a function that did this but the two I have found are giving me strange results--one creates a 36 bit integer from a floating point number (tried some examples) and another can create an estimated floating point number but it doesn't seem to be very close to the real floating point number.

๐ŸŒ
Evanw
evanw.github.io โ€บ float-toy
Float Toy
Click on a cell below to toggle bit values, or edit the hex or decimal values directly. Use this to build intuition for the IEEE floating-point format.
๐ŸŒ
Binary Convert
binaryconvert.com โ€บ result_float.html
Float (IEEE754 Single precision 32-bit)
Online binary converter. Supports all types of variables, including single and double precision IEEE754 numbers
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-convert-binary-data-to-float-in-python
How to Convert Binary Data to Float in Python? - GeeksforGeeks
July 23, 2025 - In this example, below code reads binary data, converts it to a float using the struct module, and prints the resulting float value along with its type.
Top answer
1 of 2
11

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.

2 of 2
2

If you do some looking around at wikipedia and other places, what you will learn is that the floating point standards (there are different ones, IEEE754 being the most commonly known because it is used on desktops, etc (dsp's will have their own sometimes which are faster to compute)) will "normalize" the number. Floating point is all about where the decimal point is, a non-floating point integer has an implied decimal point to the right of the number

00111111010000000000000000000000. <--- here

other than all zeros to normalize lets assume we are using a format that wants the number to be 1.xxxx in binary so we need to move our decimal point

001.11111010000000000000000000000

the decimal place was moved just after the most significant one (so that only one 1 is to the left of the decimal point).

if you remember from math in high school 123 can be written as 1.23 * 10^2 (ten to the power 2). 123 is also 123 * 10^0. Each place that you move the decimal left in a base 10 number increases the power of 10 by one. Each place to the right decreases. No different in binary which is base 2, each place you move the decimal left you increase the power of 2 (binary is base 2) each place right, you decrease the power of 2.

So to be accurate our number is now

1.1111101 * 2^30

Now the details of the floating point format come into play. Because the 1 to the left of the decimal point (Except for the exact number zero and some other exceptions) is assumed to be there, it is sometimes not in the final binary representation for that floating point number, it is a waste of space to put a bit we know is always one when we could instead have one more bit for mantissa. The mantissas are often wysiwyg in the binary, the exponent is the one that leaves you scratching your head, esp with IEEE754. An exponent of 128 for example in the binary format for the number might represent 2 to the power 0 a 129 might be 2 to the power 1 and so on. this may seem strange but it is nothing more than a twos complement field for some of these formats, others have other ways do do things. Single, double, extended have different numbers of bits for the exponent and you need to figure out what you add to the real exponent (30 in this case) to get the bit pattern that goes in the exponent field of the floating point number.

another example

0000000000000000000000000000000000000101

would be

1.01 * 2^2

if you start with a 32 bit integer (not float) and want to end up with a 32 bit floating point number you obviously cannot retain all the detail of that number, since the floating point number needs a sign bit and an exponent as well as the mantissa, the mantissa is less than 32 bits so you throw away the least significant bits

1000000000000000000000000000001  

will get chopped off at some point:

1.000000000000000 * 2^something
๐ŸŒ
101 Computing
101computing.net โ€บ home โ€บ python challenges โ€บ floating point binary converter
Floating Point Binary Converter - 101 Computing
August 11, 2024 - The purpose of this challenge is ... input, a binary number expressed using a normalised floating point representation (using a 5-bit mantissa and a 3-bit exponent). The program will then calculate the decimal value matching the input. The following conversion tool will help you work out the formula used to convert a normalised ...
๐ŸŒ
Reddit
reddit.com โ€บ r/askcomputerscience โ€บ how are float numbers converted from binary to decimal?
r/AskComputerScience on Reddit: How are float numbers converted from binary to decimal?
August 23, 2024 -

Suppose we can convert a binary integer to a decimal one repeatedly finding the remainder from dividing by ten and looking it up in a table of digits, that way for 10101 weโ€™d first divide it by ten and get a remainder of 1 which maps to 1, then weโ€™d divide it by ten once more and get a remainder of of 10, which maps to 2. That way weโ€™d get 21.

But how would I get 0.75 from 0.11?

Top answer
1 of 3
8
To handle the fractional part, you use a very similar approach, except that instead of dividing by 10 and working right-to-left, you multiply by 10 and work left-to-right. To find the first decimal digit of 0.75, you multiply it by 10 to get 7.5 and take the integer part. In binary, this corresponds to: 0.11b ร— 1010b = 111.10b The integer part of this is 111b = 7, giving you the digit 7, and the fractional part is 0.10b = 0.5. Repeat as necessary for the remaining digits. The tricky part is knowing when to stop. This process will always eventually terminate with a fractional part equal to zero, giving you an exact decimal equivalent to your binary fraction. But in practice, that may be many more digits than necessary. What you typically want is to output the minimum number of decimal digits so that the resulting decimal number rounds to your original binary number, within the precision of whatever floating-point type you're using. For instance, the decimal fraction 0.1 has no finite representation in binary. If you try to store it in a single-precision float (which has only 23 significant bits of precision, equivalent to roughly 7 decimal digits), the closest you can get is rounding it to the binary fraction .00011001100110011001101b. This binary fraction is exactly equal to the decimal number 0.100000001490116119384765625. But most of those digits are unnecessary since a single-precision float can't represent nearly that much precision. Ideally, you want to convert this number back to just "0.1" in decimal, since that will give you exactly the same number using fewer digits. This series of articles goes into a lot more detail about how binary-to-decimal float conversion is done using a minimal number of digits.
2 of 3
1
0.11 * 100 = 11 (base 2) n * 4 = 3 (base 10) n = 3/4