struct
#include <muu/half.h>
half A 16-bit "half-precision" IEEE754 floating point type.
This type is equipped with the full set of operators you'd expect from a float type, and is capable of being converted to other floats and integers, as well as direct construction using the _f16
literal:
// creation from other floats and integers is explicit: auto f1 = muu::half{ 1.0f }; auto f2 = static_cast<muu::half>(2); // promotion to larger float types is implicit (to mimic the behaviour of the built-ins): double f3 = f2; // using the _f16 literal using namespace muu::literals; auto f4 = 4.0_f16; // arithmetic operators auto f5 = 4.0_f16 * 5.0_f16; // result is a half auto f6 = 4.0_f16 * 5.0; // result is a double because of promotion auto f7 = 4.0_f16 * 5; // result is a half because of promotion // comparison operators auto b1 = 4.0_f16 <= 5.0_f16; auto b2 = 4.0_f16 <= 5.0; auto b3 = 4.0_f16 <= 5;
Public types
-
using constants = muu::
constants<half> - Static constants for this type.
Public static functions
Function documentation
half operator""_f16(long double val) consteval noexcept
Literal for creating a half-precision float.
const half val = 42.5_f16;
half operator""_f16(unsigned long long val) consteval noexcept
Literal for creating a half-precision float.
const half val = 42_f16;