Float format explorer: IEEE 754, bfloat16, FP8
Type a number or a bit pattern and see how an IEEE 754 format, bfloat16 or FP8 stores it — the fields, the exact value, its neighbours and the error.
- Limit
- up to 64 bits; round to nearest, ties to even, only
- Published
- Authorship
- Drafted with AI assistance, reviewed by İsmail
A decimal such as 0.1 or 1e-7, Infinity or NaN, or a pattern: 0x3dcccccd, 0b1…, 32'h3dcc_cccd.
Left and right arrows move between bits; Space or Enter toggles one.
normal 0.100000001 0x3dcccccd
- Sign
0- Exponent
1230b011110112−4- Fraction
50331650b10011001100110011001101- Pattern
0x3dcccccd32'h3dcc_cccd- Class
- normal
- Value
- (−1)0 × 2123 − 127 × (1 + 5033165 / 223)exactly
0.100000001490116119384765625to 9 significant digits0.100000001 - Next below
0.09999999403953552246093750x3dccccccgap0.000000007450580596923828125- Next above
0.100000008940696716308593750x3dcccccegap0.000000007450580596923828125- Error
- stored − entered
0.0000000014901161193847656250.2of the gaprelative, about1.49e-8
- Largest finite
- about
3.40282347e+380x7f7fffff - Smallest normal
- about
1.17549435e-380x00800000 - Smallest subnormal
- about
1.40129846e-450x00000001 - Precision
- p = 24 bits, about
7.22decimal digits9 significant digits read back to the same value
Round to nearest, ties to even, only.
How to read the display
The bits come first, the most significant on the left, in bytes of two nibbles with each nibble's hex digit under it. The line above them marks the fields: the sign, the exponent and the fraction, solid over the first two and dashed over the fraction. Every bit is a button. Pressing one flips it, and the input then shows the new pattern instead of what you typed.
Under the bits, one line stays in view while you work: the class of the value — zero, subnormal, normal, infinity or NaN — the value rounded to as many significant digits as always read back to the same pattern, and the pattern in hex.
The readout takes the pattern apart. The exponent field is shown with the power of two it stands for: E − bias for a normal number, 1 − bias for a subnormal one. The value is given three ways: as the formula its fields make, exactly, and rounded. An exact value can be long, because every binary fraction ends but may take a thousand digits to do it; past forty significant digits it is folded, and every digit is one press away.
Next below and next above are the values on either side, with their patterns and the gap to each. The two gaps differ at every power of two above the smallest normal number, where the gap toward zero is half the gap away from it. When you have typed a decimal, the error says how far the stored value is from it: exactly, as a fraction of the gap it was rounded across, which is at most one half unless a value beyond the largest finite one was saturated, and relative to what you typed.
The format's own limits close the readout: the largest finite value, the smallest normal and subnormal values, and the precision, p bits, in decimal digits two ways. The first, p·log102, is the precision itself; the second is the number of significant digits that is always enough to write a value and read it back unchanged.
The method
Nothing on the way passes through a JavaScript number. What you type is read exactly, as an integer and a power of ten, and rounded once to the format: to nearest, ties to even. IEEE 754 makes that the default for binary formats (section 4.3.3); OFP8 (section 5.2.1) and MX (sections 5.3.2 and 5.3.3) require an implementation to provide it and allow other modes besides. Rounding through binary32 or a double first can give a different answer next to a tie. In E4M3, 464 + 2−17 is 464 in binary32, which then rounds down to 448; rounded directly, it is past the largest value.
When a value rounds past the largest finite value, the explorer stores what a non-saturating conversion gives, an infinity or a NaN where the format has one, and names beside it what a saturating conversion gives. A format with neither saturates.
The formats
binary16, binary32 and binary64 are IEEE 754-2019's, whose table 3.5 gives their widths and biases. bfloat16 comes from Google Brain, then an AI research group at Google: the format was conceived there and is named after it (brain floating point). It is binary32 with its fraction cut to seven bits, as Intel defines it in the first volume of its software developer's manual (section 4.2.3.1) and in its BF16 numerics white paper. Intel's conversion instruction and Google's Cloud TPU flush subnormals to zero when they convert from binary32, and the explorer does not, because it shows the format and not a machine.
TF32 is NVIDIA's, from its A100 architecture whitepaper and its PTX instruction set: a sign bit,
eight exponent bits and ten fraction bits, with binary32's range. NVIDIA publishes neither its bias
nor its codes for infinity and NaN, and PTX leaves the layout of its bits to the implementation, so
the explorer shows nineteen bits with binary32's bias and rule. On the A100, the one conversion PTX
offers from binary32 to TF32, cvt.rna, rounds ties away from zero, not to even.
E4M3 and E5M2 are the formats of the OCP 8-bit Floating Point Specification, revision 1.1. E4M3 has no infinities and one NaN code for each sign, so its top exponent holds numbers up to 448; E5M2 follows the IEEE rule. The specification defines conversion only from binary32, binary16 and bfloat16, and requires both a saturating and a non-saturating mode (section 5.2.1); which NaN code a conversion produces, and its sign, it leaves to the implementation. The explorer keeps the sign, and for E5M2 uses the NaN whose fraction is 10.
FP6 E2M3, FP6 E3M2 and FP4 E2M1 are three of the element formats of the OCP Microscaling Formats specification, version 1.0 (sections 5.3.2 and 5.3.3): every code is a finite number, and a value too large saturates. The specification does not say which sign a value too small to keep rounds to, and leaves converting a NaN to the implementation: the explorer keeps the sign and refuses a NaN. The scale an MX block shares, E8M0, has no sign and no fraction and cannot be written as these formats are, so the explorer leaves it out.
Limits
Round to nearest, ties to even, and nothing else: no directed rounding, no stochastic rounding. Binary formats only, no decimal ones, of up to 64 bits: an exponent of 2 to 11 bits, a fraction of 1 to 52, a bias from 0 to 2e − 1. The explorer shows what a format holds, not what a machine does with it: flushing subnormals to zero and saturating conversions are the hardware's choices. Input is at most 2,400 characters, enough to paste back any value it stores, written out exactly.