NAG Fortran Compiler, Release 7.2: Half precision floating-point

Navigation: Previous Up Next

## 2.12 Half precision floating-point

Half precision (16-bit) floating-point is supported for values and variables of type `REAL` and `COMPLEX`. This floating-point kind conforms to the IEEE arithmetic standard (ISO/IEC/IEEE 60559:2011).

The intrinsic function `SELECTED_REAL_KIND(3)` and intrinsic module function `IEEE_SELECTED_REAL_KIND(3)` return the kind value for half precision. In -kind=byte mode, the value will be two; in -kind=sequential mode, it will be 16 (this unusual value was chosen to maintain upward compatibility of kind numbers).

The largest finite half-precision value is `65504.0`, the smallest normal half-precision value is `0.00006103515625`, and the smallest subnormal value is `0.000000059604644775390625`.

Scalar half-precision operations are evaluated in single precision, and only rounded to half precision when assigned to a variable or passed as an actual argument to a non-intrinsic or non-mathematical procedure (e.g. `SQRT` is mathematical, but `NEAREST` is not). This can be controlled by the -round_hreal option; if used, all half-precision operations will be rounded to half precision, both at compile time and run time.

Because of all the conversions needed, half precision is slower than single precision; its sole benefit is halving the memory and file storage requirements.