half
1.12
IEEE 754based halfprecision floating point library

Halfprecision floating point type. More...
Public Member Functions  
Construction and assignment  
constexpr  half () noexcept 
Default constructor.  
half (float rhs)  
Conversion constructor.  
operator float () const  
Conversion to singleprecision.  
half &  operator= (float rhs) 
Singleprecision assignment.  
Arithmetic updates  
half &  operator+= (half rhs) 
Arithmetic assignment.  
half &  operator= (half rhs) 
Arithmetic assignment.  
half &  operator*= (half rhs) 
Arithmetic assignment.  
half &  operator/= (half rhs) 
Arithmetic assignment.  
half &  operator+= (float rhs) 
Arithmetic assignment.  
half &  operator= (float rhs) 
Arithmetic assignment.  
half &  operator*= (float rhs) 
Arithmetic assignment.  
half &  operator/= (float rhs) 
Arithmetic assignment.  
Increment and decrement  
half &  operator++ () 
Prefix increment.  
half &  operator () 
Prefix decrement.  
half  operator++ (int) 
Postfix increment.  
half  operator (int) 
Postfix decrement.  
Halfprecision floating point type.
This class implements an IEEEconformant halfprecision floating point type with the usual arithmetic operators and conversions. It is implicitly convertible to singleprecision floating point, which makes artihmetic expressions and functions with mixedtype operands to be of the most precise operand type. Additionally all arithmetic operations (and many mathematical functions) are carried out in singleprecision internally. All conversions from single to halfprecision are done using the library's default rounding mode, but temporary results inside chained arithmetic expressions are kept in singleprecision as long as possible (while of course still maintaining a strong halfprecision type).
According to the C++98/03 definition, the half type is not a POD type. But according to C++11's less strict and extended definitions it is both a standard layout type and a trivially copyable type (even if not a POD type), which means it can be standardconformantly copied using raw binary copies. But in this context some more words about the actual size of the type. Although the half is representing an IEEE 16bit type, it does not neccessarily have to be of exactly 16bits size. But on any reasonable implementation the actual binary representation of this type will most probably not ivolve any additional "magic" or padding beyond the simple binary representation of the underlying 16bit IEEE number, even if not strictly guaranteed by the standard. But even then it only has an actual size of 16 bits if your C++ implementation supports an unsigned integer type of exactly 16 bits width. But this should be the case on nearly any reasonable platform.
So if your C++ implementation is not totally exotic or imposes special alignment requirements, it is a reasonable assumption that the data of a half is just comprised of the 2 bytes of the underlying IEEE representation.

noexcept 
Default constructor.
This initializes the half to 0. Although this does not match the builtin types' defaultinitialization semantics and may be less efficient than no initialization, it is needed to provide proper valueinitialization semantics.

explicit 
Conversion constructor.
rhs  float to convert 
operator float  (  )  const 
Conversion to singleprecision.
half& operator=  (  float  rhs  ) 
Singleprecision assignment.
rhs  singleprecision value to copy from 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
E  type of concrete half expression 
rhs  half to add 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
E  type of concrete half expression 
rhs  half to subtract 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
E  type of concrete half expression 
rhs  half to multiply with 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
E  type of concrete half expression 
rhs  half to divide by 
half& operator+=  (  float  rhs  ) 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
rhs  singleprecision value to add 
half& operator=  (  float  rhs  ) 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
rhs  singleprecision value to subtract 
half& operator*=  (  float  rhs  ) 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
rhs  singleprecision value to multiply with 
half& operator/=  (  float  rhs  ) 
Arithmetic assignment.
This operation uses the underlying singleprecision implementation.
rhs  singleprecision value to divide by 
half& operator++  (  ) 
Prefix increment.
This operation uses the underlying singleprecision implementation.
half& operator  (  ) 
Prefix decrement.
This operation uses the underlying singleprecision implementation.
half operator++  (  int  ) 
Postfix increment.
This operation uses the underlying singleprecision implementation.
half operator  (  int  ) 
Postfix decrement.
This operation uses the underlying singleprecision implementation.