The 16-bit IEEE half-precision storage format, with conversions to and from float32 and the Math vector and matrix types.
A Float16 holds only the bits (1 sign, 5 exponent, 10 significand): it has no arithmetic of its own, so convert to float32, compute, and convert back. Half precision has about three decimal digits, a largest finite value of 65504, and subnormals down to 2^-24.
Show moreShow less
The module parameter ASSERT_ON_OVERFLOW (default false) turns a finite value too large for a half, which otherwise becomes infinity, into a failed assert: #import "Float16"(ASSERT_ON_OVERFLOW = true).
Converts a half to float32. Every half value is exactly representable, so the conversion is exact: subnormals, signed zero and infinities carry over, and a NaN stays a NaN with its payload.
A half-precision float stored as its 16 bits. It is a distinct type based on u16, so a value cannot be mixed with integers or floats by accident; cast(u16) h gives the raw bits and cast(Float16) bits builds one from them.
A 3x3 matrix of Float16, with the same field names (_11 to _33) and the same row-major floats overlay as Math.Matrix3. Convert with matrix3_float32 and matrix3_float16.