HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
openvdb::OPENVDB_VERSION_NAME::math::internal::half Class Reference

#include <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...
 
halfoperator= (const half &h) noexcept=default
 Assignment. More...
 
halfoperator= (half &&h) noexcept=default
 Move assignment. More...
 
halfoperator= (float f) noexcept
 Assignment from float. More...
 
halfoperator+= (half h) noexcept
 Addition assignment. More...
 
halfoperator+= (float f) noexcept
 Addition assignment from float. More...
 
halfoperator-= (half h) noexcept
 Subtraction assignment. More...
 
halfoperator-= (float f) noexcept
 Subtraction assignment from float. More...
 
halfoperator*= (half h) noexcept
 Multiplication assignment. More...
 
halfoperator*= (float f) noexcept
 Multiplication assignment from float. More...
 
halfoperator/= (half h) noexcept
 Division assignment. More...
 
halfoperator/= (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...
 

Detailed Description

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:

  • float is an IEEE 754 single-precision number
  • sizeof (float) == 4
  • sizeof (unsigned int) == sizeof (float)
  • alignof (unsigned int) == alignof (float)
  • sizeof (uint16_t) == 2

Definition at line 502 of file Half.h.

Member Typedef Documentation

using openvdb::OPENVDB_VERSION_NAME::math::internal::half::uif = imath_half_uif

Definition at line 642 of file Half.h.

Constructor & Destructor Documentation

openvdb::OPENVDB_VERSION_NAME::math::internal::half::half ( )
defaultnoexcept

Default construction provides no initialization (hence it is not constexpr).

openvdb::OPENVDB_VERSION_NAME::math::internal::half::half ( float  f)
inlinenoexcept

Construct from float.

Definition at line 656 of file Half.h.

constexpr openvdb::OPENVDB_VERSION_NAME::math::internal::half::half ( FromBitsTag  ,
uint16_t  bits 
)
inlinenoexcept

Construct from bit-vector.

Definition at line 665 of file Half.h.

constexpr openvdb::OPENVDB_VERSION_NAME::math::internal::half::half ( const half )
defaultnoexcept

Copy constructor.

constexpr openvdb::OPENVDB_VERSION_NAME::math::internal::half::half ( half &&  )
defaultnoexcept

Move constructor.

openvdb::OPENVDB_VERSION_NAME::math::internal::half::~half ( )
defaultnoexcept

Destructor.

Member Function Documentation

constexpr uint16_t openvdb::OPENVDB_VERSION_NAME::math::internal::half::bits ( ) const
inlinenoexcept

Return the bit pattern.

Definition at line 886 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isDenormalized ( ) const
inlinenoexcept

Return true if a denormalized number.

Definition at line 832 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isFinite ( ) const
inlinenoexcept

Return true if a normalized number, a denormalized number, or zero.

Definition at line 820 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isInfinity ( ) const
inlinenoexcept

Return true if a positive or a negative infinity.

Definition at line 850 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isNan ( ) const
inlinenoexcept

Return true if NAN.

Definition at line 844 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isNegative ( ) const
inlinenoexcept

Return true if the sign bit is set (negative)

Definition at line 856 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isNormalized ( ) const
inlinenoexcept

Return true if a normalized number.

Definition at line 826 of file Half.h.

constexpr bool openvdb::OPENVDB_VERSION_NAME::math::internal::half::isZero ( ) const
inlinenoexcept

Return true if zero.

Definition at line 838 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::negInf ( )
inlinestaticnoexcept

Return -infinity.

Definition at line 868 of file Half.h.

openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator float ( ) const
inlinenoexcept

Conversion to float.

Definition at line 672 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator*= ( half  h)
inlinenoexcept

Multiplication assignment.

Definition at line 780 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator*= ( float  f)
inlinenoexcept

Multiplication assignment from float.

Definition at line 787 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator+= ( half  h)
inlinenoexcept

Addition assignment.

Definition at line 752 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator+= ( float  f)
inlinenoexcept

Addition assignment from float.

Definition at line 759 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator- ( ) const
inlinenoexcept

Unary minus.

Definition at line 739 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator-= ( half  h)
inlinenoexcept

Subtraction assignment.

Definition at line 766 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator-= ( float  f)
inlinenoexcept

Subtraction assignment from float.

Definition at line 773 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator/= ( half  h)
inlinenoexcept

Division assignment.

Definition at line 794 of file Half.h.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator/= ( float  f)
inlinenoexcept

Division assignment from float.

Definition at line 801 of file Half.h.

half& openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator= ( const half h)
defaultnoexcept

Assignment.

half& openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator= ( half &&  h)
defaultnoexcept

Move assignment.

half & openvdb::OPENVDB_VERSION_NAME::math::internal::half::operator= ( float  f)
inlinenoexcept

Assignment from float.

Definition at line 745 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::posInf ( )
inlinestaticnoexcept

Return +infinity.

Definition at line 862 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::qNan ( )
inlinestaticnoexcept

Returns a NAN with the bit pattern 0111111111111111.

Definition at line 874 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::round ( unsigned int  n) const
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.

Definition at line 682 of file Half.h.

constexpr void openvdb::OPENVDB_VERSION_NAME::math::internal::half::setBits ( uint16_t  bits)
inlinenoexcept

Set the bit pattern.

Definition at line 892 of file Half.h.

constexpr half openvdb::OPENVDB_VERSION_NAME::math::internal::half::sNan ( )
inlinestaticnoexcept

Return a NAN with the bit pattern 0111110111111111.

Definition at line 880 of file Half.h.


The documentation for this class was generated from the following file: