IEEE 754 Float Converter
See the sign, exponent and fraction bits of half, single and double precision floats, the exact value stored, the rounding error and the neighbouring floats.
The interactive tool loads here when JavaScript runs.
About this toolWhat is the IEEE 754 Float Converter?
Type a number and the IEEE 754 Float Converter shows how a computer stores it as a half (binary16), single (binary32, float) or double (binary64) precision float: the sign bit, the exponent bits with their bias, the fraction bits, the hex pattern and the bytes in both byte orders. Or switch to "Bits to number" and paste a hex pattern such as 3DCCCCCD from a debugger or a file to see what it means.
The tool shows the exact decimal value of the stored float, not a rounded display. 0.1 as a float is really 0.100000001490116119384765625, and as a double 0.1000000000000000055511151231257827021181583404541015625. Next to it are the rounding error, the shortest decimal that reads back to the same bits, the next float up and down, and the gap between neighbours at that size.
It covers the whole format: zeros of both signs, subnormals down to the smallest one, infinities, and NaNs with their quiet bit and payload. Click any bit to flip it and see the value change, which is the quickest way to learn what the exponent and fraction fields do.
- Half (binary16), single (binary32) and double (binary64) precision
- Encode decimals, fractions, hex floats, infinities and NaN; decode hex or binary patterns
- Exact decimal value of the stored number and the rounding error
- Shortest round-trip decimal, nextUp, nextDown and the gap to the next float
- Subnormals, signed zeros, infinities and NaN payloads labelled
- Clickable bits, both byte orders, a three-format comparison, runs in your browser
Updated
How to use the IEEE 754 Float Converter
- Choose "Number to bits" and a format: half (16-bit), single (32-bit) or double (64-bit).
- Type a decimal (0.1, -6.25, 6.02e23), an exact fraction (1/3), a C hex float (0x1.8p3), inf or nan.
- Read the coloured bit fields, the hex pattern, the exact stored value and the rounding error. The table compares the same number in all three formats.
- To decode a pattern, choose "Bits to number" and paste the hex (3DCCCCCD) or binary with a 0b prefix. Click any bit to flip it.
- Copy the exact value or all results, or share a link to the same conversion.
Worked examples
0.1 as a float
Input
0.1, single precision
Output
0x3DCCCCCD: sign 0, exponent 01111011 (123 - 127 = -4), fraction 10011001100110011001101
Stored value 0.100000001490116119384765625, about 1.49 × 10^-9 too high. The repeating 1100 of 0.1 in binary is cut after 23 bits and rounded up, which is why the pattern ends in ...CD rather than ...CC.
Integers stop being exact at 2^24 in a float
Input
16777217, single precision
Output
Stored as 16,777,216 (0x4B800000), error -1
Above 2^24 the gap between neighbouring floats is 2, so odd integers fall exactly halfway and round to the even neighbour. In double precision the same thing starts at 2^53.
A bit pattern from a file
Input
40490FDB, bits to number, single precision
Output
3.1415927410125732421875, shortest form 3.1415927
This is the float closest to π, the value M_PI becomes when stored in a C float. Reading the same four bytes in the opposite order (DB0F4940) gives -40,331,460,896,358,400, a common symptom of a byte order mix-up.
The smallest positive float
Input
00000001, bits to number, single precision
Output
Subnormal, 2^-149, about 1.4 × 10^-45
With the exponent field at zero the implicit bit is 0, so the last fraction bit alone is worth 2^-149. The exact decimal has 105 significant digits, all shown.
Background and insight
IEEE 754, first published in 1985 and revised in 2008 and 2019, defines how nearly every processor and programming language stores floating-point numbers. A binary float has three fields: one sign bit, an exponent stored with a bias (15 for binary16, 127 for binary32, 1023 for binary64) and a trailing significand, the fraction. For normal numbers the significand has an implicit leading 1, so binary32 stores 23 fraction bits but has 24 bits of precision, and binary64 stores 52 for 53. The value is (-1)^sign × 1.fraction × 2^(exponent - bias).
An exponent field of all zeros means zero or a subnormal number: the leading bit becomes 0 and the exponent is fixed at its minimum, so values fade gradually towards zero instead of jumping to it. That is why the smallest binary32 is about 1.4 × 10^-45 rather than the 1.18 × 10^-38 of the smallest normal number. An exponent field of all ones means infinity when the fraction is zero and NaN otherwise. IEEE 754-2019 recommends that the first fraction bit mark a quiet NaN; the remaining bits are a payload that some systems use to carry diagnostic information.
Converting a decimal to binary almost always rounds, because most decimal fractions repeat in binary. The default rule, roundTiesToEven, picks the nearest representable value and breaks exact ties towards an even last bit. This tool rounds directly from the exact decimal in one step. Converting to a double first and then to a float, as Math.fround(parseFloat(s)) does, rounds twice and can be one unit off in rare cases close to a tie; the tool's tests include one. JavaScript numbers are binary64, and the ECMAScript spec prints them with the shortest digits that read back to the same double, which is why 0.1 displays as 0.1 even though it is not stored exactly.
Common use cases
Debugging floating-point surprises
See exactly what 0.1, 0.2 and their sum are stored as, and why a comparison or a total is off in the last digit.
Reading binary files and network data
Decode a float32 or float64 from a hex dump, sensor packet or GPU buffer, in either byte order.
Choosing float16, float32 or float64
Compare the precision lost by each format for your values before shrinking a model, texture or data file.
Teaching and exams
Work IEEE 754 conversions by hand and check the sign, biased exponent, fraction, subnormals and special values.
Tips and limitations
- Decoding expects the pattern in big-endian order, most significant byte first, as you would write it in source code. If your bytes come from x86 or ARM memory, reverse them first; the tool shows both orders for every value.
- A float holds 6 to 9 significant decimal digits and a double 15 to 17. Printing more digits than that shows the binary rounding, not extra accuracy.
- Use a fraction such as 1/3 to get the correctly rounded float of a value that has no finite decimal form.
- NaN typed as input becomes the default quiet NaN. To inspect a NaN with a payload or a signalling NaN, decode its bit pattern.
- For money, store integer cents or use a decimal type. Binary floats cannot hold most decimal fractions exactly, at any precision.
Sources and further reading
- IEEE 754-2019: Standard for Floating-Point Arithmetic, IEEE Standards Association. Formats (Table 3.5), roundTiesToEven, nextUp and NaN encoding
- What every computer scientist should know about floating-point arithmetic, ACM Computing Surveys. David Goldberg, 1991: rounding, subnormals and why they matter
- ECMAScript Language Specification: The Number Type, Ecma International TC39. JavaScript numbers are binary64; Number::toString prints the shortest round-trip digits
- DataView, MDN Web Docs. Reading and writing float32 and float64 values in either byte order
Frequently asked questions
How do I convert a decimal number to IEEE 754 single precision by hand?
Write the number in binary, normalise it to 1.xxx × 2^e, add the bias 127 to e for the exponent field, and keep the 23 bits after the point as the fraction, rounding to nearest. For -6.25: binary 110.01 = 1.1001 × 2^2, sign 1, exponent 129 = 10000001, fraction 1001 then zeros, giving 0xC0C80000.
Why is the exponent stored with a bias?
A biased exponent is a plain unsigned number, so two positive floats compare in the same order as their bit patterns read as integers. Bias 127 lets binary32 exponents run from -126 to 127, with the all-zeros and all-ones fields kept for subnormals, zeros, infinities and NaN.
What is a subnormal (denormal) number?
A float whose exponent field is zero. Its implicit leading bit is 0 instead of 1 and its exponent is fixed at the minimum, so it fills the gap between zero and the smallest normal number with evenly spaced values. They keep x - y from being zero when x and y differ, at the cost of precision.
What is the difference between a quiet and a signalling NaN?
IEEE 754-2019 recommends using the first fraction bit: 1 marks a quiet NaN that passes through arithmetic silently, 0 with a non-zero fraction marks a signalling NaN meant to raise an invalid-operation exception when used. The other fraction bits are the payload.
Why does a float show 0.1 if it cannot store 0.1?
Languages print the shortest decimal that rounds back to the same bits. 0x3DCCCCCD is the float nearest 0.1, so "0.1" identifies it uniquely, even though its exact value is 0.100000001490116119384765625.
How many decimal digits does each format hold?
Binary16 keeps 3 to 5 significant digits, binary32 6 to 9 and binary64 15 to 17. The lower number is how many digits always survive a decimal to binary to decimal round trip; the higher is how many you need to print to reproduce every value exactly.
Why does reading a float from a file give a huge or tiny nonsense value?
Usually the byte order is wrong. The float 1.0 is 3F 80 00 00 in big-endian order and 00 00 80 3F in little-endian order; read the little-endian bytes as big-endian and you get a subnormal near 4.6 × 10^-41.
Is there an in-depth guide to the IEEE 754 Float Converter?
Yes. “Binary, Hex and IEEE 754 Floats, Bit by Bit” covers the background, how it works, common pitfalls and worked examples. Read the full guide.
Related Tools You May Like
Free, in-browser tools that pair well with this one.