sargon.halffloat
Implement IEEE 754 half-precision binary floating point format binary16. This a 16 bit type, and consists of a sign bit, a 5 bit exponent, and a 10 bit significand. All operations on HalfFloat are CTFE'able. References:Wikipedia License:
Boost License 1.0 Authors:
Walter Bright Source:
src/sargon/halffloat.d
- struct HalfFloat;
- The half precision floating point type.
The only operations are:
It operates in an analogous manner to shorts, which are converted to ints
before performing any operations, and explicitly cast back to shorts.
The half float is considered essentially a storage type, not a computation type.
Example:
HalfFloat h = hf!27.2f; HalfFloat j = cast(HalfFloat)( hf!3.5f + hf!5 ); HalfFloat f = HalfFloat(0.0f);
BUGS:
The only rounding mode currently supported is Round To Nearest. The exceptions OVERFLOW, UNDERFLOW and INEXACT are not thrown. - template hf(float v)
- User defined literal for Half Float.
Example:
auto h = hf!1.3f;