Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Burger::Half Class Reference

Container for a 16 bit float. More...

Public Member Functions

 Half () noexcept
 Constructor.
 
 Half (float16_t uData) noexcept
 Constructor with 16 bit float.
 
 Half (float fInput) noexcept
 Constructor with 32 bit float.
 
 operator float () const noexcept
 Convert to a 32 bit float.
 
 operator uint16_t () const noexcept
 Return the 16 bit float.
 
uint_t is_finite () const noexcept
 Test if the value is finite.
 
uint_t is_infinity () const noexcept
 Test if the value is infinite.
 
uint_t is_nan () const noexcept
 Test if the value is NaN.
 
uint_t is_normalized () const noexcept
 Test if the value is normalzed.
 
uint_t is_denormalized () const noexcept
 Test if the value is denormalzed.
 
uint_t is_zero () const noexcept
 Test if the value is zero.
 
uint_t is_negative () const noexcept
 Test if the value is negative.
 
Half operator- () const noexcept
 Return a negated Half.
 
Halfoperator= (const Half &rInput) noexcept
 Copy a Half class.
 
Halfoperator= (float fInput) noexcept
 Assign a 32 bit float to this class.
 
Halfoperator+= (const Half &rInput) noexcept
 Add a Half to this Half.
 
Halfoperator+= (float fInput) noexcept
 Add a float to this Half.
 
Halfoperator-= (const Half &rInput) noexcept
 Subtract a Half from this Half.
 
Halfoperator-= (float fInput) noexcept
 Subtract a float to this Half.
 
Halfoperator*= (const Half &rInput) noexcept
 Multiply a Half with this Half.
 
Halfoperator*= (float fInput) noexcept
 Multiply a float to this Half.
 
Halfoperator/= (const Half &rInput) noexcept
 Divide a Half from this Half.
 
Halfoperator/= (float fInput) noexcept
 Divide a float from this Half.
 

Private Attributes

float16_t m_uData
 Binary representation of a 16 bit float.
 

Detailed Description

Container for a 16 bit float.


This class will allow math functions to be applied to a 16 bit float since most "C" compilers don't have native support for the data type.

While this class exists, it is recommended to perform math operations with float or double until a final result is created and then the result is converted to the float16 data type.

See also
convert_to_float16(float), or convert_to_float(float16_t)

Constructor & Destructor Documentation

◆ Half() [1/3]

Burger::Half::Half ( )
inlinenoexcept

Constructor.


This constructor does NOT initialize this class.

See also
Half(float16_t), or Half(float)

◆ Half() [2/3]

Burger::Half::Half ( float16_t uData)
inlinenoexcept

Constructor with 16 bit float.


Initialize with a 16 bit float.

See also
Half(float), or Half()

◆ Half() [3/3]

Burger::Half::Half ( float fInput)
noexcept

Constructor with 32 bit float.


Initialize with a 32 bit float, which is converted into a 16 bit float.

See also
Half(float16_t), or Half()

Member Function Documentation

◆ is_denormalized()

uint_t Burger::Half::is_denormalized ( ) const
inlinenoexcept

Test if the value is denormalzed.


If the contained value is denormalized, return TRUE

Returns
TRUE or FALSE
See also
is_normalized() const

◆ is_finite()

uint_t Burger::Half::is_finite ( ) const
inlinenoexcept

Test if the value is finite.


If the contained value is a finite value, return TRUE

Returns
TRUE or FALSE
See also
is_infinity() const, or is_nan() const

◆ is_infinity()

uint_t Burger::Half::is_infinity ( ) const
inlinenoexcept

Test if the value is infinite.


If the contained value is a infinite value, return TRUE

Returns
TRUE or FALSE
See also
is_finite() const, or is_nan() const

◆ is_nan()

uint_t Burger::Half::is_nan ( ) const
inlinenoexcept

Test if the value is NaN.


If the contained value is a NaN (Not a Number) value, return TRUE

Returns
TRUE or FALSE
See also
is_finite() const, or is_infinity() const

◆ is_negative()

uint_t Burger::Half::is_negative ( ) const
inlinenoexcept

Test if the value is negative.


If the contained value has the sign bit set, return TRUE

Returns
TRUE or FALSE
See also
is_zero() const

◆ is_normalized()

uint_t Burger::Half::is_normalized ( ) const
inlinenoexcept

Test if the value is normalzed.


If the contained value is normalized, return TRUE

Returns
TRUE or FALSE
See also
is_denormalized() const

◆ is_zero()

uint_t Burger::Half::is_zero ( ) const
inlinenoexcept

Test if the value is zero.


If the contained value is zero, return TRUE

Note
It will check for both positive and negative zero.
Returns
TRUE or FALSE
See also
is_negative() const

◆ operator float()

Burger::Half::operator float ( ) const
noexcept

Convert to a 32 bit float.


Convert the float 16 into a 32 bit float and return the float.

See also
operator uint16_t()

◆ operator uint16_t()

Burger::Half::operator uint16_t ( ) const
inlinenoexcept

Return the 16 bit float.


See also
operator float()

◆ operator*=() [1/2]

Burger::Half & Burger::Half::operator*= ( const Half & rInput)
noexcept

Multiply a Half with this Half.


Convert both inputs into floats, perform a multiplication, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
rInputHalf to multiply to this instance.
Returns
*this

◆ operator*=() [2/2]

Burger::Half & Burger::Half::operator*= ( float fInput)
noexcept

Multiply a float to this Half.


Convert this class into a float, perform a multiplication, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
fInput32 bit float to multiply with this Half
Returns
*this

◆ operator+=() [1/2]

Burger::Half & Burger::Half::operator+= ( const Half & rInput)
noexcept

Add a Half to this Half.


Convert both inputs into floats, perform an addition, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
rInputHalf to add to this instance.
Returns
*this

◆ operator+=() [2/2]

Burger::Half & Burger::Half::operator+= ( float fInput)
noexcept

Add a float to this Half.


Convert this class into a float, perform an addition, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
fInput32 bit float to add to this Half
Returns
*this

◆ operator-()

Burger::Half Burger::Half::operator- ( ) const
noexcept

Return a negated Half.


Negate the float16 and return that result as a newly created Half class.

Returns
Half class with the value negated from this value

◆ operator-=() [1/2]

Burger::Half & Burger::Half::operator-= ( const Half & rInput)
noexcept

Subtract a Half from this Half.


Convert both inputs into floats, perform a subtraction, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
rInputHalf to subtract from this instance.
Returns
*this

◆ operator-=() [2/2]

Burger::Half & Burger::Half::operator-= ( float fInput)
noexcept

Subtract a float to this Half.


Convert this class into a float, perform a subtraction, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
fInput32 bit float to subtract from this Half
Returns
*this

◆ operator/=() [1/2]

Burger::Half & Burger::Half::operator/= ( const Half & rInput)
noexcept

Divide a Half from this Half.


Convert both inputs into floats, perform a division, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
rInputHalf to divide from this instance.
Returns
*this

◆ operator/=() [2/2]

Burger::Half & Burger::Half::operator/= ( float fInput)
noexcept

Divide a float from this Half.


Convert this class into a float, perform a division, and then store the result in this class.

Note
Due to conversions, this function is not as fast as performing hardware float operations.
Parameters
fInput32 bit float to divide from this Half
Returns
*this

◆ operator=() [1/2]

Burger::Half & Burger::Half::operator= ( const Half & rInput)
noexcept

Copy a Half class.


Copy the contents of the supplied Half into this instance.

Parameters
rInputHalf to copy to this instance.
Returns
*this

◆ operator=() [2/2]

Burger::Half & Burger::Half::operator= ( float fInput)
noexcept

Assign a 32 bit float to this class.


Convert the 32 bit float into a 16 bit float and store the 16 bit value in this instance of this class.

Parameters
fInput32 bit float to convert to a 16 bit float.
Returns
*this

Member Data Documentation

◆ m_uData

float16_t Burger::Half::m_uData
private

Binary representation of a 16 bit float.