#include <math/half.h>
Type HalfFloat behaves (almost) like the built-in C++ floating point types. In arithmetic expressions, HalfFloat, float and double can be mixed freely. Here are a few examples:
HalfFloat a (3.5); float b (a + sqrt (a)); a += b; b += a; b = a + 7;
Conversions from HalfFloat to float are lossless; all HalfFloat numbers are exactly representable as floats.
Conversions from float to HalfFloat may not preserve the float's value exactly. If a float is not representable as a HalfFloat, the float value is rounded to the nearest representable HalfFloat. If a float value is exactly in the middle between the two closest representable HalfFloat values, then the float value is rounded to the HalfFloat with the greater magnitude.
Overflows during float-to-HalfFloat conversions cause arithmetic exceptions. An overflow occurs when the float value to be converted is too large to be represented as a HalfFloat, or if the float value is an infinity or a NAN.
The implementation of type HalfFloat makes the following assumptions about the implementation of the built-in C++ types:
float is an IEEE 754 single-precision number sizeof (float) == 4 sizeof (unsigned int) == sizeof (float) alignof (unsigned int) == alignof (float) sizeof (unsigned short) == 2
Public Member Functions | |
| HalfFloat () | |
| Construct uninitialized number. | |
| HalfFloat (float val) | |
| Construct from 32-bit floating point number. | |
| operator float () const | |
| Convert to 32-bit floating point number. | |
| neo::math::HalfFloat::HalfFloat | ( | float | val | ) | [inline] |
| val | Value |
1.5.1