OpenVDB
12.0.0
|
#include <openvdb/math/Half.h>
Public Types | |
using | uif = imath_half_uif |
Public Member Functions | |
operator float () const noexcept | |
Conversion to float. More... | |
constexpr half | round (unsigned int n) const noexcept |
Constructors | |
half () noexcept=default | |
half (float f) noexcept | |
Construct from float. More... | |
constexpr | half (FromBitsTag, uint16_t bits) noexcept |
Construct from bit-vector. More... | |
constexpr | half (const half &) noexcept=default |
Copy constructor. More... | |
constexpr | half (half &&) noexcept=default |
Move constructor. More... | |
~half () noexcept=default | |
Destructor. More... | |
Basic Algebra | |
constexpr half | operator- () const noexcept |
Unary minus. More... | |
half & | operator= (const half &h) noexcept=default |
Assignment. More... | |
half & | operator= (half &&h) noexcept=default |
Move assignment. More... | |
half & | operator= (float f) noexcept |
Assignment from float. More... | |
half & | operator+= (half h) noexcept |
Addition assignment. More... | |
half & | operator+= (float f) noexcept |
Addition assignment from float. More... | |
half & | operator-= (half h) noexcept |
Subtraction assignment. More... | |
half & | operator-= (float f) noexcept |
Subtraction assignment from float. More... | |
half & | operator*= (half h) noexcept |
Multiplication assignment. More... | |
half & | operator*= (float f) noexcept |
Multiplication assignment from float. More... | |
half & | operator/= (half h) noexcept |
Division assignment. More... | |
half & | operator/= (float f) noexcept |
Division assignment from float. More... | |
Classification | |
constexpr bool | isFinite () const noexcept |
constexpr bool | isNormalized () const noexcept |
Return true if a normalized number. More... | |
constexpr bool | isDenormalized () const noexcept |
Return true if a denormalized number. More... | |
constexpr bool | isZero () const noexcept |
Return true if zero. More... | |
constexpr bool | isNan () const noexcept |
Return true if NAN. More... | |
constexpr bool | isInfinity () const noexcept |
Return true if a positive or a negative infinity. More... | |
constexpr bool | isNegative () const noexcept |
Return true if the sign bit is set (negative) More... | |
Access to the internal representation | |
constexpr uint16_t | bits () const noexcept |
Return the bit pattern. More... | |
constexpr void | setBits (uint16_t bits) noexcept |
Set the bit pattern. More... | |
Static Public Member Functions | |
Special values | |
static constexpr half | posInf () noexcept |
Return +infinity. More... | |
static constexpr half | negInf () noexcept |
Return -infinity. More... | |
static constexpr half | qNan () noexcept |
Returns a NAN with the bit pattern 0111111111111111. More... | |
static constexpr half | sNan () noexcept |
Return a NAN with the bit pattern 0111110111111111. More... | |
class half – 16-bit floating point number
Type half can represent positive and negative numbers whose magnitude is between roughly 6.1e-5 and 6.5e+4 with a relative error of 9.8e-4; numbers smaller than 6.1e-5 can be represented with an absolute error of 6.0e-8. All integers from -2048 to +2048 can be represented exactly.
Type half behaves (almost) like the built-in C++ floating point types. In arithmetic expressions, half, float and double can be mixed freely. Here are a few examples:
half a (3.5); float b (a + sqrt (a)); a += b; b += a; b = a + 7;
Conversions from half to float are lossless; all half numbers are exactly representable as floats.
Conversions from float to half may not preserve a float's value exactly. If a float is not representable as a half, then the float value is rounded to the nearest representable half. If a float value is exactly in the middle between the two closest representable half values, then the float value is rounded to the closest half whose least significant bit is zero.
Overflows during float-to-half conversions cause arithmetic exceptions. An overflow occurs when the float value to be converted is too large to be represented as a half, or if the float value is an infinity or a NAN.
The implementation of type half makes the following assumptions about the implementation of the built-in C++ types:
using uif = imath_half_uif |
|
defaultnoexcept |
Default construction provides no initialization (hence it is not constexpr).
|
inlinenoexcept |
Construct from float.
|
inlinenoexcept |
Construct from bit-vector.
|
defaultnoexcept |
Destructor.
|
inlinenoexcept |
Return the bit pattern.
|
inlinenoexcept |
Return true if a denormalized number.
|
inlinenoexcept |
Return true if a normalized number, a denormalized number, or zero.
|
inlinenoexcept |
Return true if a positive or a negative infinity.
|
inlinenoexcept |
Return true if NAN.
|
inlinenoexcept |
Return true if the sign bit is set (negative)
|
inlinenoexcept |
Return true if a normalized number.
|
inlinenoexcept |
Return true if zero.
|
inlinestaticnoexcept |
Return -infinity.
|
inlinenoexcept |
Conversion to float.
|
inlinenoexcept |
Multiplication assignment from float.
|
inlinenoexcept |
Addition assignment from float.
|
inlinenoexcept |
Unary minus.
|
inlinenoexcept |
Subtraction assignment from float.
|
inlinenoexcept |
Division assignment from float.
|
inlinenoexcept |
Assignment from float.
|
inlinestaticnoexcept |
Return +infinity.
|
inlinestaticnoexcept |
Returns a NAN with the bit pattern 0111111111111111.
|
inlinenoexcept |
Round to n-bit precision (n should be between 0 and 10). After rounding, the significand's 10-n least significant bits will be zero.
|
inlinenoexcept |
Set the bit pattern.
|
inlinestaticnoexcept |
Return a NAN with the bit pattern 0111110111111111.