On ARM and AArch64 targets, GCC supports half-precision (16-bit) floating point via the
type defined in the ARM C Language Extensions. On ARM systems, you must enable this type explicitly with the
command-line option in order to use it.
ARM targets support two incompatible representations for half-precision floating-point values. You must choose one of the representations and use it consistently in your program.
Specifying -mfp16-format=ieee selects the IEEE 754-2008 format. This format can represent normalized values in the range of 2^-14 to 65504. There are 11 bits of significand precision, approximately 3 decimal digits.
Specifying -mfp16-format=alternative selects the ARM alternative format. This representation is similar to the IEEE format, but does not support infinities or NaNs. Instead, the range of exponents is extended, so that this format can represent normalized values in the range of 2^-14 to 131008.
The GCC port for AArch64 only supports the IEEE 754-2008 format, and does not require use of the -mfp16-format command-line option.
type may only be used as an argument to intrinsics defined in
, or as a storage format. For purposes of arithmetic and other operations,
values in C or C++ expressions are automatically promoted to
The ARM target provides hardware support for conversions between
values as an extension to VFP and NEON (Advanced SIMD), and from ARMv8-A provides hardware support for conversions between
values. GCC generates code using these hardware instructions if you compile with options to select an FPU that provides them; for example,
, in addition to the
option to select a half-precision format.
Language-level support for the
data type is independent of whether GCC generates code using hardware floating-point instructions. In cases where hardware support is not specified, GCC implements conversions between
and other types as library calls.
It is recommended that portable code use the
type defined by ISO/IEC TS 18661-3:2015. See Floating Types