IEEE 754 Converter
Paste floats, one per line, as decimals, hex or binary bits. Get the IEEE 754 bits, the exact stored value and the rounding error. Nothing leaves your browser.
Also: Float to Hex, Hex to Float, Float to Bin
- 0
- Numbers
- 0
- Rounded
- 0
- Errors
On this page
About the IEEE 754 Converter
Updated
The IEEE 754 Converter shows how a computer stores a floating-point number. Paste decimals like 0.1, hex bits like 0x3DCCCCCD or binary bits, and get the other forms back. It works in all five common formats: 16-bit half, bfloat16, 32-bit single, 64-bit double and 128-bit quad.
Every number is rounded the way the standard says: once, to the nearest float, and on an exact half to the even one. The tool does the math with exact fractions, so 16777217 becomes 16777216 in 32-bit, as in C. When a number is rounded, Results shows the exact value that is stored and how far it is from what you wrote.
Most converters take one number. This one takes a whole list, from a log, a register dump or a spreadsheet column, and marks each bad line at its bad character.
The same tool, set up for other jobs: Float to Hex, Hex to Float, Float to Binary. For whole numbers in any base, use the Number Base Converter.
How to use it
- Paste decimals, hex bits or binary bits, one per line, or load a file. Tabs, semicolons and a comma with a space after it also split a line.
- Pick the Format: 16-bit half, bfloat16, 32-bit single, 64-bit double or 128-bit quad. It is in the Result header. On a phone it is under More.
- Check From and To, next to Convert. On a phone they are under More.
- Press Convert (Alt C). Results shows each answer and how much it was rounded. When a number is rounded, the Value column shows the exact value that is stored. A long value is cut short there, and Bits shows all of it. Output has only the answers, for Copy and Download.
- Open Bits to see the sign, exponent and mantissa of one number. Click a bit to flip it, or step to the next float up or down. Steps shows the work by hand.
- Swap (Alt S) puts the answers in the editor and turns From and To around, so you can check the way back.
How a float is stored
A float has three fields. Here is 0.1 in 32-bit:
Sign Exponent Mantissa
0 01111011 10011001100110011001101
Sign 0 positive
Exponent 01111011 123 - 127 = -4
Mantissa 1.10011001100110011001101 (binary) = 1.6000000238418579
Value +1.6000000238418579 x 2^-4 = 0.100000001490116119384765625
Hex 3DCCCCCDThe exponent is stored with a bias, 127 for 32-bit, so it needs no sign bit of its own. The mantissa has a hidden 1 in front: it is not stored, because every normal number starts with it. That gives 24 bits of precision from 23 stored bits.
The five formats
Format Bits Sign Exponent Mantissa Bias Digits Largest
half 16 1 5 10 15 3.3 65504
bfloat16 16 1 8 7 127 2.4 3.39e38
single 32 1 8 23 127 7.2 3.40e38
double 64 1 11 52 1023 16.0 1.80e308
quad 128 1 15 112 16383 34.0 1.19e4932The digits column is how many decimal digits each format holds. bfloat16 has the exponent of a 32-bit float and a short mantissa, so it keeps the range and drops precision. Half precision does the opposite: more precision than bfloat16, but nothing above 65504.
Special values
00000000 0 all zeros
80000000 -0 sign bit only
00000001 1e-45 smallest subnormal
00800000 1.1754944e-38 smallest normal
7F7FFFFF 3.4028235e+38 largest
7F800000 Infinity exponent all ones, mantissa zero
FF800000 -Infinity
7FC00000 NaN quiet: top mantissa bit 1
7F800001 NaN signaling: top mantissa bit 0To try one here, put 0x in front. From is Auto on this page, and Auto reads 00800000 as a decimal but 0x00800000 as hex bits.
Common errors
A decimal comma
In much of Europe, one and a half is written 1,5. Other converters read it as 1 or as 0, with no warning. This tool marks the comma. A comma with a space after it splits two numbers, so a list such as 0.1, 0.2 still works.
1,5
Decimal comma. Write 1.5 with a point. For two numbers, put a space
after the comma.1.5An exponent with no digits
A number copied from a log can lose its end. The tool marks the e.
6.02e
Exponent has no digits. Put the power of ten after the e: 1e5 or 2.5e-3.6.02e23A whole number that is not exact
This one is not an error, but it surprises people. A 32-bit float holds every whole number up to 16,777,216 (2^24). Past that, only every second one. 16777217 is stored as 16777216, and the tool says so in a note.
IEEE 754 in code
C uint32_t u; memcpy(&u, &f, 4); printf("%08X", u);
printf("%a", 0.1); // 0x1.999999999999ap-4
Python struct.pack(">f", 0.1).hex() # '3dcccccd'
struct.unpack(">f", bytes.fromhex("3dcccccd"))[0]
(0.1).hex() # '0x1.999999999999ap-4'
JavaScript const dv = new DataView(new ArrayBuffer(4));
dv.setFloat32(0, 0.1); dv.getUint32(0).toString(16)
Java Float.floatToIntBits(0.1f) // 0x3DCCCCCD
Float.intBitsToFloat(0x3DCCCCCD)In C, never cast a float pointer to an int pointer: it breaks the aliasing rules. Copy the bytes with memcpy. In Python, > is big-endian and < is little-endian.
IEEE 754 resources
- IEEE 754 on WikipediaThe standard itself: the formats, the rounding rules, Infinity and NaN, and its history since 1985.
- Single-precision floating-point formatThe 32-bit float bit by bit, with worked examples and the exact limits.
- Double-precision floating-point formatThe 64-bit double that JavaScript, Python and most languages use for every number.
- Half-precision floating-point formatThe 16-bit float of GPUs and graphics, with its small range: the largest is 65504.
- bfloat16 on WikipediaThe 16-bit float for machine learning: the range of a 32-bit float with 8 bits of precision.
- What Every Computer Scientist Should Know About Floating-Point ArithmeticDavid Goldberg's classic paper on rounding error, guard digits and why floats behave as they do.
- Floating Point Math (0.30000000000000004.com)What 0.1 + 0.2 gives in each programming language, and why.
IEEE 754 FAQ
What is the IEEE 754 format?
IEEE 754 is the standard for floating-point numbers that almost every CPU and language uses. A float is stored in three parts: a sign bit, an exponent and a mantissa (also called the fraction or significand). The value is (-1)^sign × 1.mantissa × 2^(exponent − bias).
A 32-bit float has 1 sign bit, 8 exponent bits with a bias of 127, and 23 mantissa bits. The standard also sets the rounding rules and the special values: ±0, ±Infinity and NaN.
What is the difference between single and double precision?
Single precision (32-bit, float) has 24 bits of precision, about 7 decimal digits, and goes up to 3.4 × 10^38. Double precision (64-bit, double) has 53 bits, about 16 digits, and goes up to 1.8 × 10^308.
Paste the same number in both formats to see the difference: 0.1 is off by about 1.5 × 10^-9 in single and 5.6 × 10^-18 in double.
Why is FP32 called single precision?
Because it was the one word of a 32-bit machine. The 64-bit format took two words, so it was double precision. FP16 is half precision and FP128 quad. The names stayed when the hardware changed.
When should I use float instead of double?
Use double by default: it is what JavaScript, Python and most math libraries use, and its error is much smaller. Use float when memory or speed matter more than digits: graphics, audio, sensor data, large arrays and GPUs.
Machine learning goes further down, to float16 and bfloat16, because a model with billions of weights needs half the memory and still trains well.
Why is 0.1 not exact in a float?
0.1 is 1/10, and 10 has a factor of 5. In binary, only fractions whose bottom number is a power of two end, so 0.1 is 0. forever. The float keeps the nearest value it can: in 32-bit that is 0.100000001490116119384765625.
Paste 0.1 here. In Results, the Value column shows that stored value, and Rounded by shows the error, +1.49e-9.
What is a subnormal number?
A number smaller than the smallest normal float. Its exponent bits are all zeros, there is no hidden 1, and it loses precision a bit at a time down to the smallest subnormal: 1e-45 in 32-bit, 5e-324 in 64-bit. Subnormals let a value fade out to 0 instead of dropping to it in one step.
How are Infinity and NaN stored?
Both have an exponent of all ones. Infinity has a mantissa of all zeros: 7F800000 is +Infinity in 32-bit. NaN has any other mantissa. If its top mantissa bit is 1 it is a quiet NaN (7FC00000); if 0, a signaling NaN. The rest of the bits are the payload, and the tool shows it.
Are my numbers sent anywhere?
No. Every number is converted in your browser, with exact BigInt math. Nothing is uploaded, and there are no ads or cookie walls. You can check this in your browser's network tab while you use it.