Skip to content
AESTECHNO
AESTECHNO
Contact
FLOAT · DOUBLE · HALF · BFLOAT16

IEEE 754 Converter: Float to Hex (Single, Double, Half and bfloat16)

An IEEE 754 float stores a sign, a biased exponent and a fraction: 1, 8 and 23 bits in binary32 (float). 0.1 is not representable exactly: it is stored as 0x3DCCCCCD, which is exactly 0.100000001490116119384765625, a rounding error of 1.49e-9. The converter works both ways and gives the bit fields, the exact stored value, the error in ulps, the bytes, and the same number as double, half and bfloat16.

Inputs

A real number, inf or nan; or a hex pattern if you pick "Hex to decimal".

Direction
The float bit by bit The bits of the float: sign, biased exponent and fraction, with the exponent decoded and the class of the value. 0 0 1 1 1 1 0 1 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 0 1 S 2^−4 1.f 0x3DCCCCCD = 0.1 sign + · exponent 123 − 127 = −4normal · binary32 (float)
Result

0x3DCCCCCD

Formula with your values

(−1)^0 × 1.fraction × 2^(123 − 127)

Breakdown

0.1 as binary32 (float) is stored as 0.1

Hex 0x3DCCCCCD
Sign · exponent · fraction 0 · 01111011 · 1001 1001 1001 1001 1001 101
Exponent 123 − 127 = -4
Class normal
Significand (binary) 1.10011001100110011001101 × 2^-4
Exact stored value 0.100000001490116119384765625
Shortest round-trip decimal 0.1
Rounding error 1.49e-9 · 0.2 ulp · 1.49e-8 relative
ulp 2^-27 = 7.45058e-9
Next down · up 0.099999994 · 0.10000001
Bytes, big-endian 3D CC CC CD
Bytes, little-endian CD CC CC 3D
C array, little-endian { 0xCD, 0xCC, 0xCC, 0x3D }
As binary16 (half) 0x2E66 = 0.1, error -0.0000244
As bfloat16 0x3DCD = 0.1, error 0.0000977
As binary64 (double) 0x3FB999999999999A = 0.1, error 5.55e-18
Largest finite 3.4028235e+38
Smallest normal · subnormal 1.1754944e-38 · 1e-45
Machine epsilon 2^−23 = 1.19209e-7
Digits for a round trip 9 significant digits (printf %.9g)

You receive the result with its direct link. Our design house gets a copy and can react to it, simply reply if you want an engineer's eye on it.

IEEE 754-2019 encoding, round to nearest with ties to even, computed with exact integers from the decimal you type: no double rounding through binary64. The exact stored value is the dyadic rational the bits encode. NaN payloads are not preserved: nan encodes as the canonical quiet NaN. Values and hex are written with a decimal point, as in code.

TOOL // IEEE 754

A misunderstood float in firmware means a reading wrong in the last digit or a test that fails at random. We write the firmware for our boards, from sensor driver to signal processing. Let's talk about your project in a free 30-minute audit.

The four float formats at a glance

Field widths, bias and limits as computed by the tool.

The four float formats to scale Four bars drawn to scale. binary16: 1 sign bit, 5 exponent bits, 10 fraction bits. bfloat16: 1, 8 and 7. binary32: 1, 8 and 23. binary64: 1, 11 and 52. bfloat16 keeps the exponent of binary32 and drops 16 fraction bits. binary16 1 · 5 · 10 bfloat16 1 · 8 · 7 binary32 1 · 8 · 23 binary64 1 · 11 · 52 (−1)^s × 1.f × 2^(e − bias) bias = 2^(exponent bits − 1) − 1
Sign, exponent and fraction bits of each format, to scale
IEEE 754 and bfloat16 formats
FormatBits (s, exp, fraction)BiasLargest finiteSmallest normalEpsilonRound-trip digits
binary16 (half)16 (1, 5, 10)15655046.1035e-52^−105
bfloat1616 (1, 8, 7)1273.39e+381.18e-382^−74
binary32 (float)32 (1, 8, 23)1273.4028235e+381.1754944e-382^−239
binary64 (double)64 (1, 11, 52)10231.7976931348623157e+3082.2250738585072014e-3082^−5217
Frequently asked questions

FAQ

How do you convert a decimal number to IEEE 754?
Write the value as 1.f × 2^e, store e + bias in the exponent (bias 127 for float, 1023 for double) and f, rounded to nearest with ties to even, in the fraction. For 0.1 as a float: 0.1 = 1.6 × 2^−4, exponent 123 (0b01111011), fraction 0x4CCCCD, giving 0x3DCCCCCD. The calculator rounds from the exact decimal fraction, not through a double, which avoids double rounding for half and bfloat16.
Why does 0.1 + 0.2 not equal 0.3?
None of the three numbers is exact in binary. As a double, 0.1 is stored as 0.1000000000000000055511151231257827..., 0.2 and 0.3 are rounded too, and the rounded sum lands on the double next to 0.3: it prints as 0.30000000000000004. Compare floats with a relative tolerance, never with ==.
How many digits do you need to print a float without loss?
9 significant digits always read back to the same float bits (FLT_DECIMAL_DIG), 17 for a double, 5 for a half and 4 for a bfloat16. So printf("%.9g") on a float is safe. The calculator also shows the shortest decimal that reads back to the same bits, which is often much shorter.
What is the difference between half (binary16) and bfloat16?
Both are 16 bits. binary16 has 5 exponent bits and 10 fraction bits: about 3 decimal digits, but a range that stops at 65504. bfloat16 keeps the float's 8 exponent bits and only 7 fraction bits: the same range as a float, about 2 to 3 digits. It is a truncated float, which is why machine learning hardware uses it.
In what order are the bytes of a float stored?
On a Cortex-M, x86 or RISC-V, little-endian: 0.1f (0x3DCCCCCD) occupies the bytes CD CC CC 3D. In a network frame or from a big-endian sensor, the order is 3D CC CC CD. The calculator gives both orders and a C array ready to paste into a unit test or a serial protocol.
What is a subnormal number?
When the stored exponent is 0, the hidden bit becomes 0 and the exponent stays at its minimum: precision is lost, but values go below the smallest normal. In a float the smallest subnormal is 2^−149, about 1.4e-45. On some processors subnormal arithmetic is much slower, or flushed to zero (flush-to-zero mode).
Go further

An electronics design house based in Montpellier, France, AESTECHNO brings 10+ years of hardware and firmware design experience and a 100% success rate on CE/FCC certifications. Encoding follows IEEE 754-2019 (round to nearest, ties to even), computed with exact integers.