
Half-precision floating-point format

In computing, half precision (sometimes called FP16) is a binary floating-point computer number format that occupies 16 bits (two bytes in modern computers) in computer memory.
They can express values in the range ±65,504, with the minimum value above 1 being 1 + 1/1024.
In the IEEE 754-2008 standard, the 16-bit base-2 format is referred to as binary16. It is intended for storage of floating-point values in applications where higher precision is not essential for performing arithmetic computations.
Although implementations of the IEEE half-precision floating point are relatively new, several earlier 16-bit floating point formats have existed including that of Hitachi's HD61810 DSP of 1982, Scott's WIF and the 3dfx Voodoo Graphics processor.
Nvidia and Microsoft defined the half datatype in the Cg language, released in early 2002, and implemented it in silicon in the GeForce FX, released in late 2002. ILM was searching for an image format that could handle a wide dynamic range, but without the hard drive and memory cost of floating-point representations that are commonly used for floating-point computation (single and double precision). The hardware-accelerated programmable shading group led by John Airey at SGI (Silicon Graphics) invented the s10e5 data type in 1997 as part of the 'bali' design effort. This is described in a SIGGRAPH 2000 paper (see section 4.3) and further documented in US patent 7518615.
This format is used in several computer graphics environments including MATLAB, OpenEXR, JPEG XR, GIMP, OpenGL, Cg, Direct3D, and D3DX. The advantage over 8-bit or 16-bit binary integers is that the increased dynamic range allows for more detail to be preserved in highlights and shadows for images. The advantage over 32-bit single-precision binary formats is that it requires half the storage and bandwidth (at the expense of precision and range).
The F16C extension allows x86 processors to convert half-precision floats to and from single-precision floats.
Depending on the computer, half-precision can be over an order of magnitude faster than double precision, e.g. 37 PFLOPS vs. for half 550 "AI-PFLOPS (Half Precision)".
IEEE 754 half-precision binary floating-point format: binary16.
The IEEE 754 standard specifies a binary16 as having the following format:
The format is laid out as follows:
The format is assumed to have an implicit lead bit with value 1 unless the exponent field is stored with all zeros. Thus only 10 bits of the significand appear in the memory format but the total precision is 11 bits. In IEEE 754 parlance, there are 10 bits of significand, but there are 11 bits of significand precision (log10(211) ≈ 3.311 decimal digits, or 4 digits ± slightly less than 5 units in the last place).
Exponent encoding.
The half-precision binary floating-point exponent is encoded using an offset-binary representation, with the zero offset being 15; also known as exponent bias in the IEEE 754 standard.
Thus, as defined by the offset binary representation, in order to get the true exponent the offset of 15 has to be subtracted from the stored exponent.
The stored exponents 000002 and 111112 are interpreted specially.
The minimum strictly positive (subnormal) value is
2−24 ≈ 5.96 × 10−8.
The minimum positive normal value is 2−14 ≈ 6.10 × 10−5.
The maximum representable value is (2−2−10) × 215 = 65504.
Half precision examples.
These examples are given in bit representation
of the floating-point value. This includes the sign bit, (biased) exponent, and significand.
 0 00000 00000000012 = 000116 = formula_1 ≈ 0.000000059604645
 (smallest positive subnormal number)
 0 00000 11111111112 = 03ff16 = formula_2 ≈ 0.000060975552
 (largest subnormal number)
 0 00001 00000000002 = 040016 = formula_3 ≈ 0.00006103515625
 (smallest positive normal number)
 0 11110 11111111112 = 7bff16 = formula_4 = 65504
 (largest normal number)
 0 01110 11111111112 = 3bff16 = formula_5 ≈ 0.99951172
 (largest number less than one)
 0 01111 00000000002 = 3c0016 = formula_6 = 1
 (one)
 0 01111 00000000012 = 3c0116 = formula_7 ≈ 1.00097656
 (smallest number larger than one)
 0 01101 01010101012 = 355516 = formula_8 = 0.33325195
 (the rounding of 1/3 to nearest)
 1 10000 00000000002 = c00016 = −2
 0 00000 00000000002 = 000016 = 0
 1 00000 00000000002 = 800016 = −0
 0 11111 00000000002 = 7c0016 = infinity
 1 11111 00000000002 = fc0016 = −infinity
By default, 1/3 rounds down like for double precision, because of the odd number of bits in the significand. The bits beyond the rounding point are codice_1 which is less than 1/2 of a unit in the last place.
ARM alternative half-precision.
ARM processors support (via a floating point control register bit) an "alternative half-precision" format, which does away with the special case for an exponent value of 31 (111112). It is almost identical to the IEEE format, but there is no encoding for infinity or NaNs; instead, an exponent of 31 encodes normalized numbers in the range 65536 to 131008.
Uses.
Hardware and software for machine learning or neural networks tend to use half precision: such applications usually do a large amount of calculation, but don't require a high level of precision.
On older computers that access 8 or 16 bits at a time (most modern computers access 32 or 64 bits at a time), half precision arithmetic is faster than single precision, and substantially faster than double precision. On systems with instructions that can handle multiple floating point numbers with in one instruction, half-precision often offers a higher average throughput.