How to use the FP8 E4M3 Converter tool
- Under Input format, select Number to quantize a decimal value to FP8, or Hexadecimal or binary bits to decode one byte.
- In Number or bit pattern, enter a value such as 0.3, a byte such as D5, or eight binary digits after 0b.
- Select Inspect bits, or use Example to convert -13.25.
- Read the stored Value and the Hex, Bits, Sign, Exponent, Fraction and Class lines. Select Copy to keep the output.
The FP8 E4M3FN layout
E4M3 means 4 exponent bits and 3 mantissa bits after 1 sign bit. The exponent bias is 7. A normal value is 1.fff x 2^(exponent - 7), and an exponent field of zero marks subnormals that step by 2^-9, or 0.001953125. The smallest normal value is 2^-6, or 0.015625.
FN stands for finite numbers and NaN. There is no infinity. The top exponent 1111 holds ordinary numbers, and only the pattern with all mantissa bits set, 0x7F or 0xFF, is NaN. That pushes the largest value to 0x7E, which is 1.75 x 2^8 = 448. The format was proposed in the 2022 paper FP8 Formats for Deep Learning and is the FLOAT8E4M3FN type in ONNX.
Worked example: -13.25 becomes 0xD5
-13.25 is -1.65625 x 2^3. With only 3 mantissa bits, the neighbors are 1.625 x 8 = 13 and 1.75 x 8 = 14, and 13 is closer. The exponent field is 3 + 7 = 10, or 1010, and the mantissa for 1.625 is 101. The byte is 1 1010 101, which is D5, and the Value line reports -13.
Value: -13
Hex: 0xD5
Bits: 11010101
Sign: 1
Exponent: 1010
Fraction: 101
Class: normalSaturation, underflow and rounding
Because the format has no infinity, out-of-range input is clamped. The tool behaves like a saturating cast.
- Any magnitude above the range becomes 448 or -448: 1000 gives 0x7E, and so does Infinity.
- Magnitudes below half of the smallest subnormal round to zero: 0.0009 gives 0x00, while 0.001 gives 0x01.
- Ties go to the even mantissa: 17 sits between 16 and 18 and becomes 16.
- Integers are exact up to 16. Near the top of the range the step between values is 32.
- NaN encodes as 0x7F. Negative zero is kept as 0x80.
E4M3FN next to other 8-bit float formats
The same paper defines E5M2, with 5 exponent and 2 mantissa bits. E5M2 keeps IEEE-style infinities and reaches 57344, at the cost of one bit of precision. A common pattern is E4M3 for weights and activations and E5M2 for gradients.
ONNX also lists FNUZ variants, which drop negative zero and shift the bias. This converter implements E4M3FN only. A byte from an E5M2 or FNUZ tensor will decode to the wrong number here.
Frequently asked questions
What is the largest value FP8 E4M3 can store?
448, encoded as 0x7E, and -448 as 0xFE. IEEE-style formats would spend the whole top exponent on infinities and NaNs. E4M3FN reuses seven of those eight mantissa codes for numbers, which extends the range from 240 to 448.
How does E4M3FN represent infinity?
It does not. The format has no infinity encoding, so this tool saturates: typing Infinity returns 448 and -Infinity returns -448. Frameworks that convert without saturation may produce NaN in that case, so check which mode yours uses.
How many different values does FP8 E4M3FN have?
A byte has 256 patterns. Two are NaN (0x7F and 0xFF) and two are zeros (0x00 and 0x80). The remaining 252 are nonzero finite numbers, 126 positive and 126 negative, of which 7 on each side are subnormal.
Why does 0.1 become 0.1015625?
With 3 mantissa bits there are only eight values per power of two. Between 0.0625 and 0.125 the step is 0.0078125, and the nearest grid point to 0.1 is 0.1015625, stored as 0x1D. The error is about 1.6 percent.
Can I decode a float16 or float32 word here?
No. Bit mode accepts one byte: up to two hex digits or eight binary digits. Longer input is rejected with a message asking for up to 2 hexadecimal digits. Use the FP16 Converter or the IEEE 754 Float32 Converter for wider formats.