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::FPInfo Class Reference

Class for analyzing a floating point number. More...

Public Member Functions

 FPInfo (void) noexcept
 Default constructor.
 
 FPInfo (uint16_t uValue) noexcept
 Constructor for 16 bit float.
 
 FPInfo (float fValue) noexcept
 Constructor for 32 bit float.
 
 FPInfo (double dValue) noexcept
 Constructor for 64 bit float.
 
void init_half (uint16_t uValue) noexcept
 Process a 16 bit floating point number.
 
void init_float (float fValue) noexcept
 Process a 32 bit floating point number.
 
void init_double (double dValue) noexcept
 Process a 64 bit floating point number.
 
uint64_t get_mantissa (void) const noexcept
 Get the mantissa value.
 
uint32_t get_biased_exponent (void) const noexcept
 Get the biased exponent.
 
int32_t get_exponent (void) const noexcept
 Get the exponent.
 
uint32_t get_mantissa_bit_count (void) const noexcept
 Get the number of bits in the mantissa.
 
uint32_t get_exponent_bit_count (void) const noexcept
 Get the number of bits in the exponent.
 
uint_t is_valid (void) const noexcept
 Detect if a number was analyzed.
 
uint_t is_negative (void) const noexcept
 Detect if a number is a negative value.
 
uint_t is_zero (void) const noexcept
 Detect if a number is zero.
 
uint_t is_NaN (void) const noexcept
 Detect if a number is Not a Number.
 
uint_t is_QNaN (void) const noexcept
 Detect if a number is a quiet Not a Number.
 
uint_t is_indefinite_NaN (void) const noexcept
 Detect if a number is an indefinite Not a Number.
 
uint_t is_infinity (void) const noexcept
 Detect if a number is infinity.
 
uint_t is_subnormal (void) const noexcept
 Detect if a number is a non normalized number.
 
uint_t is_finite (void) const noexcept
 Detect if a number is a finite number.
 
FPInfooperator= (uint16_t usValue) noexcept
 Process a 16 bit floating point number.
 
FPInfooperator= (float fValue) noexcept
 Process a 32 bit floating point number.
 
FPInfooperator= (double dValue) noexcept
 Process a 64 bit floating point number.
 

Private Attributes

uint64_t m_uMantissa
 The mantissa value for the floating point number.
 
uint32_t m_uBiasedExponent
 Exponent as stored in the floating point number.
 
int32_t m_iExponent
 Exponent with bias applied.
 
uint32_t m_uMantissaBitCount
 Number of bits in the mantissa.
 
uint32_t m_uExponentBitCount
 Number of bits in the exponent.
 
uint32_t m_uFlags
 Flags that contain the determined states.
 

Static Private Attributes

static constexpr const uint32_t kSignBit16 = 0x8000U
 Location of the sign bit in a 16 bit float.
 
static constexpr const uint32_t kExponentMask16 = 0x7C00U
 Mask for the exponent in a 16 bit float.
 
static constexpr const uint32_t kMantissaMask16 = 0x03FFU
 Mask for the mantissa in a 16 bit float.
 
static constexpr const uint32_t kImplicitBit16 = 0x0400U
 Implicit "1" bit for a 16 bit float.
 
static constexpr const uint32_t kMantissaBitCount16 = 10
 Number of bits in the mantissa for a 16 bit float.
 
static constexpr const uint32_t kExponentBitCount16 = 5
 Number of bits in the exponent for a 16 bit float.
 
static constexpr const uint32_t kExponentBias16 = 15
 Bias of the exponent for a 16 bit float.
 
static constexpr const uint32_t kSpecialExponent16 = 0x1FU
 Special exponent for INF/NAN in a 16 bit float.
 
static constexpr const uint32_t kNANTypeBit16 = 0x0200U
 QNAN or SNAN bit in a 16 bit float.
 
static constexpr const uint32_t kSignBit32 = 0x80000000U
 Location of the sign bit in a 32 bit float.
 
static constexpr const uint32_t kExponentMask32 = 0x7F800000U
 Mask for the exponent in a 32 bit float.
 
static constexpr const uint32_t kMantissaMask32 = 0x007FFFFFU
 Mask for the mantissa in a 32 bit float.
 
static constexpr const uint32_t kImplicitBit32 = 0x00800000U
 Implicit "1" bit for a 32 bit float.
 
static constexpr const uint32_t kMantissaBitCount32 = 23
 Number of bits in the mantissa for a 32 bit float.
 
static constexpr const uint32_t kExponentBitCount32 = 8
 Number of bits in the exponent for a 32 bit float.
 
static constexpr const uint32_t kExponentBias32 = 127
 Bias of the exponent for a 32 bit float.
 
static constexpr const uint32_t kSpecialExponent32 = 0xFFU
 Special exponent for INF/NAN in a 32 bit float.
 
static constexpr const uint32_t kNANTypeBit32 = 0x00400000U
 QNAN or SNAN bit in a 32 bit float.
 
static constexpr const uint64_t kSignBit64 = 0x8000000000000000ULL
 Location of the sign bit in a 64 bit float.
 
static constexpr const uint64_t kExponentMask64
 Mask for the exponent in a 64 bit float.
 
static constexpr const uint64_t kMantissaMask64
 Mask for the mantissa in a 64 bit float.
 
static constexpr const uint64_t kImplicitBit64
 Implicit "1" bit for a 64 bit float.
 
static constexpr const uint32_t kMantissaBitCount64 = 52
 Number of bits in the mantissa for a 64 bit float.
 
static constexpr const uint32_t kExponentBitCount64 = 11
 Number of bits in the exponent for a 64 bit float.
 
static constexpr const uint32_t kExponentBias64 = 1023
 Bias of the exponent for a 64 bit float.
 
static constexpr const uint32_t kSpecialExponent64 = 0x7FFU
 Special exponent for INF/NAN in a 64 bit float.
 
static constexpr const uint64_t kNANTypeBit64
 QNAN or SNAN bit in a 64 bit float.
 
static constexpr const uint32_t kFlagValidShift = 0U
 Flag that's set if a floating point number was analyzed.
 
static constexpr const uint32_t kFlagNegativeShift = 1U
 Flag that's set if the number is negative.
 
static constexpr const uint32_t kFlagZeroShift = 2U
 Flag that's set if the number is zero.
 
static constexpr const uint32_t kFlagNANShift = 3U
 Flag that's set if the number is a "Not a Number".
 
static constexpr const uint32_t kFlagQNANShift = 4U
 Flag that's set if the number is a quiet "Not a Number".
 
static constexpr const uint32_t kFlagIndefiniteNANShift = 5U
 Flag that's set if the number is an unknown "Not a Number".
 
static constexpr const uint32_t kFlagInfinityShift = 6U
 Flag that's set if the number is infinite.
 
static constexpr const uint32_t kFlagSubNormalShift = 7U
 Flag that's set if the number is not normalized.
 

Detailed Description

Class for analyzing a floating point number.


Submitting a number into this class causes it to be broken down into its components so it can be queried as to the floating point behaviors this number represents.

It's useful for printing functions or number analysis functions.

For lightweight tests, use the explicit calls such at is_NaN(float), is_infinite(double), etc

When a floating point number is assigned to this class, it is broken down to the type of value (Infinity, NaN, Subnormal), the mantissa, the exponent and the sign. The values can be accessed with the calls get_mantissa(), get_exponent(), get_mantissa_bit_count(), etc.

See also
is_NaN(float), is_NaN(), get_mantissa(), get_exponent()

Constructor & Destructor Documentation

◆ FPInfo() [1/4]

Burger::FPInfo::FPInfo ( void )
explicitnoexcept

Default constructor.


All values are set to zero. Use the Init() functions or assignment operators to perform floating point analysis.

See also
init_float(float), or FPInfo::operator = (float)

◆ FPInfo() [2/4]

Burger::FPInfo::FPInfo ( uint16_t uValue)
explicitnoexcept

Constructor for 16 bit float.


Parameters
uValue16 bit floating point number
See also
init_half(uint16_t), FPInfo(double) or FPInfo(float)

◆ FPInfo() [3/4]

Burger::FPInfo::FPInfo ( float fValue)
explicitnoexcept

Constructor for 32 bit float.


Parameters
fValue32 bit floating point number
See also
init_float(float), FPInfo(uint16_t) or FPInfo(double)

◆ FPInfo() [4/4]

Burger::FPInfo::FPInfo ( double dValue)
explicitnoexcept

Constructor for 64 bit float.


Parameters
dValue64 bit floating point number
See also
init_double(double), FPInfo(uint16_t) or FPInfo(float)

Member Function Documentation

◆ get_biased_exponent()

uint32_t Burger::FPInfo::get_biased_exponent ( void ) const
inlinenoexcept

Get the biased exponent.


Returns
The exponent value as it was stored in the floating point number

◆ get_exponent()

int32_t Burger::FPInfo::get_exponent ( void ) const
inlinenoexcept

Get the exponent.


Returns the exponent as it was meant to be represented, as such, it's a signed integer.

Returns
The exponent value of the floating point number

◆ get_exponent_bit_count()

uint32_t Burger::FPInfo::get_exponent_bit_count ( void ) const
inlinenoexcept

Get the number of bits in the exponent.


Returns
The exponent size in bits of the analyzed floating point number

◆ get_mantissa()

uint64_t Burger::FPInfo::get_mantissa ( void ) const
inlinenoexcept

Get the mantissa value.


Returns
The mantissa of the analyzed floating point number

◆ get_mantissa_bit_count()

uint32_t Burger::FPInfo::get_mantissa_bit_count ( void ) const
inlinenoexcept

Get the number of bits in the mantissa.


Returns
The mantissa size in bits of the analyzed floating point number

◆ init_double()

void BURGER_API Burger::FPInfo::init_double ( double dValue)
noexcept

Process a 64 bit floating point number.


Given a 64 bit floating point number, process it into its component parts.

Parameters
dValue64 bit float point number

◆ init_float()

void BURGER_API Burger::FPInfo::init_float ( float fValue)
noexcept

Process a 32 bit floating point number.


Given a 32 bit floating point number, process it into its component parts.

Parameters
fValue32 bit float point number

◆ init_half()

void BURGER_API Burger::FPInfo::init_half ( uint16_t uValue)
noexcept

Process a 16 bit floating point number.


Given a 16 bit floating point number, process it into its component parts.

Parameters
uValue16 bit float point number

◆ is_finite()

uint_t Burger::FPInfo::is_finite ( void ) const
inlinenoexcept

Detect if a number is a finite number.


If the number is infinity or NaN, it will return FALSE. Otherwise it will return TRUE.

Returns
TRUE if the number is finite, FALSE if it is.
See also
is_finite(float) or is_finite(double)

◆ is_indefinite_NaN()

uint_t Burger::FPInfo::is_indefinite_NaN ( void ) const
inlinenoexcept

Detect if a number is an indefinite Not a Number.


Returns
TRUE if the number is an indefinite Not a Number, FALSE if it's a valid number

◆ is_infinity()

uint_t Burger::FPInfo::is_infinity ( void ) const
inlinenoexcept

Detect if a number is infinity.


Returns
TRUE if the number is infinity, FALSE if it's not
See also
is_infinite(float) or is_infinite(double)

◆ is_NaN()

uint_t Burger::FPInfo::is_NaN ( void ) const
inlinenoexcept

Detect if a number is Not a Number.


This returns TRUE for all forms of Not a Number.

Returns
TRUE if the number is Not a Number, FALSE if it's a valid number
See also
is_NaN(float) or is_NaN(double)

◆ is_negative()

uint_t Burger::FPInfo::is_negative ( void ) const
inlinenoexcept

Detect if a number is a negative value.


Returns
TRUE if the number is negative, FALSE if not

◆ is_QNaN()

uint_t Burger::FPInfo::is_QNaN ( void ) const
inlinenoexcept

Detect if a number is a quiet Not a Number.


Returns
TRUE if the number is a quiet Not a Number, FALSE if it's a valid number

◆ is_subnormal()

uint_t Burger::FPInfo::is_subnormal ( void ) const
inlinenoexcept

Detect if a number is a non normalized number.


Returns
TRUE if the number is not normalized, FALSE if it is.

◆ is_valid()

uint_t Burger::FPInfo::is_valid ( void ) const
inlinenoexcept

Detect if a number was analyzed.


Returns
TRUE if an analyzed number is stored in the class, FALSE if not.

◆ is_zero()

uint_t Burger::FPInfo::is_zero ( void ) const
inlinenoexcept

Detect if a number is zero.


This returns TRUE for both positive and negative zero.

Returns
TRUE if the number is zero, FALSE if not

◆ operator=() [1/3]

FPInfo & Burger::FPInfo::operator= ( double dValue)
inlinenoexcept

Process a 64 bit floating point number.


Given a 64 bit floating point number, process it into its component parts.

Parameters
dValue64 bit float point number

◆ operator=() [2/3]

FPInfo & Burger::FPInfo::operator= ( float fValue)
inlinenoexcept

Process a 32 bit floating point number.


Given a 32 bit floating point number, process it into its component parts.

Parameters
fValue32 bit float point number

◆ operator=() [3/3]

FPInfo & Burger::FPInfo::operator= ( uint16_t usValue)
inlinenoexcept

Process a 16 bit floating point number.


Given a 16 bit floating point number, process it into its component parts.

Parameters
usValue16 bit float point number

Member Data Documentation

◆ kExponentBias16

const uint32_t Burger::FPInfo::kExponentBias16 = 15
staticconstexprprivate

Bias of the exponent for a 16 bit float.

◆ kExponentBias32

const uint32_t Burger::FPInfo::kExponentBias32 = 127
staticconstexprprivate

Bias of the exponent for a 32 bit float.

◆ kExponentBias64

const uint32_t Burger::FPInfo::kExponentBias64 = 1023
staticconstexprprivate

Bias of the exponent for a 64 bit float.

◆ kExponentBitCount16

const uint32_t Burger::FPInfo::kExponentBitCount16 = 5
staticconstexprprivate

Number of bits in the exponent for a 16 bit float.

◆ kExponentBitCount32

const uint32_t Burger::FPInfo::kExponentBitCount32 = 8
staticconstexprprivate

Number of bits in the exponent for a 32 bit float.

◆ kExponentBitCount64

const uint32_t Burger::FPInfo::kExponentBitCount64 = 11
staticconstexprprivate

Number of bits in the exponent for a 64 bit float.

◆ kExponentMask16

const uint32_t Burger::FPInfo::kExponentMask16 = 0x7C00U
staticconstexprprivate

Mask for the exponent in a 16 bit float.

◆ kExponentMask32

const uint32_t Burger::FPInfo::kExponentMask32 = 0x7F800000U
staticconstexprprivate

Mask for the exponent in a 32 bit float.

◆ kExponentMask64

const uint64_t Burger::FPInfo::kExponentMask64
staticconstexprprivate
Initial value:
=
0x7FF0000000000000ULL

Mask for the exponent in a 64 bit float.

◆ kFlagIndefiniteNANShift

const uint32_t Burger::FPInfo::kFlagIndefiniteNANShift = 5U
staticconstexprprivate

Flag that's set if the number is an unknown "Not a Number".

◆ kFlagInfinityShift

const uint32_t Burger::FPInfo::kFlagInfinityShift = 6U
staticconstexprprivate

Flag that's set if the number is infinite.

◆ kFlagNANShift

const uint32_t Burger::FPInfo::kFlagNANShift = 3U
staticconstexprprivate

Flag that's set if the number is a "Not a Number".

◆ kFlagNegativeShift

const uint32_t Burger::FPInfo::kFlagNegativeShift = 1U
staticconstexprprivate

Flag that's set if the number is negative.

◆ kFlagQNANShift

const uint32_t Burger::FPInfo::kFlagQNANShift = 4U
staticconstexprprivate

Flag that's set if the number is a quiet "Not a Number".

◆ kFlagSubNormalShift

const uint32_t Burger::FPInfo::kFlagSubNormalShift = 7U
staticconstexprprivate

Flag that's set if the number is not normalized.

◆ kFlagValidShift

const uint32_t Burger::FPInfo::kFlagValidShift = 0U
staticconstexprprivate

Flag that's set if a floating point number was analyzed.

◆ kFlagZeroShift

const uint32_t Burger::FPInfo::kFlagZeroShift = 2U
staticconstexprprivate

Flag that's set if the number is zero.

◆ kImplicitBit16

const uint32_t Burger::FPInfo::kImplicitBit16 = 0x0400U
staticconstexprprivate

Implicit "1" bit for a 16 bit float.

◆ kImplicitBit32

const uint32_t Burger::FPInfo::kImplicitBit32 = 0x00800000U
staticconstexprprivate

Implicit "1" bit for a 32 bit float.

◆ kImplicitBit64

const uint64_t Burger::FPInfo::kImplicitBit64
staticconstexprprivate
Initial value:
=
0x0010000000000000ULL

Implicit "1" bit for a 64 bit float.

◆ kMantissaBitCount16

const uint32_t Burger::FPInfo::kMantissaBitCount16 = 10
staticconstexprprivate

Number of bits in the mantissa for a 16 bit float.

◆ kMantissaBitCount32

const uint32_t Burger::FPInfo::kMantissaBitCount32 = 23
staticconstexprprivate

Number of bits in the mantissa for a 32 bit float.

◆ kMantissaBitCount64

const uint32_t Burger::FPInfo::kMantissaBitCount64 = 52
staticconstexprprivate

Number of bits in the mantissa for a 64 bit float.

◆ kMantissaMask16

const uint32_t Burger::FPInfo::kMantissaMask16 = 0x03FFU
staticconstexprprivate

Mask for the mantissa in a 16 bit float.

◆ kMantissaMask32

const uint32_t Burger::FPInfo::kMantissaMask32 = 0x007FFFFFU
staticconstexprprivate

Mask for the mantissa in a 32 bit float.

◆ kMantissaMask64

const uint64_t Burger::FPInfo::kMantissaMask64
staticconstexprprivate
Initial value:
=
0x000FFFFFFFFFFFFFULL

Mask for the mantissa in a 64 bit float.

◆ kNANTypeBit16

const uint32_t Burger::FPInfo::kNANTypeBit16 = 0x0200U
staticconstexprprivate

QNAN or SNAN bit in a 16 bit float.

◆ kNANTypeBit32

const uint32_t Burger::FPInfo::kNANTypeBit32 = 0x00400000U
staticconstexprprivate

QNAN or SNAN bit in a 32 bit float.

◆ kNANTypeBit64

const uint64_t Burger::FPInfo::kNANTypeBit64
staticconstexprprivate
Initial value:
=
0x0008000000000000ULL

QNAN or SNAN bit in a 64 bit float.

◆ kSignBit16

const uint32_t Burger::FPInfo::kSignBit16 = 0x8000U
staticconstexprprivate

Location of the sign bit in a 16 bit float.

◆ kSignBit32

const uint32_t Burger::FPInfo::kSignBit32 = 0x80000000U
staticconstexprprivate

Location of the sign bit in a 32 bit float.

◆ kSignBit64

const uint64_t Burger::FPInfo::kSignBit64 = 0x8000000000000000ULL
staticconstexprprivate

Location of the sign bit in a 64 bit float.

◆ kSpecialExponent16

const uint32_t Burger::FPInfo::kSpecialExponent16 = 0x1FU
staticconstexprprivate

Special exponent for INF/NAN in a 16 bit float.

◆ kSpecialExponent32

const uint32_t Burger::FPInfo::kSpecialExponent32 = 0xFFU
staticconstexprprivate

Special exponent for INF/NAN in a 32 bit float.

◆ kSpecialExponent64

const uint32_t Burger::FPInfo::kSpecialExponent64 = 0x7FFU
staticconstexprprivate

Special exponent for INF/NAN in a 64 bit float.

◆ m_iExponent

int32_t Burger::FPInfo::m_iExponent
private

Exponent with bias applied.

◆ m_uBiasedExponent

uint32_t Burger::FPInfo::m_uBiasedExponent
private

Exponent as stored in the floating point number.

◆ m_uExponentBitCount

uint32_t Burger::FPInfo::m_uExponentBitCount
private

Number of bits in the exponent.

◆ m_uFlags

uint32_t Burger::FPInfo::m_uFlags
private

Flags that contain the determined states.

◆ m_uMantissa

uint64_t Burger::FPInfo::m_uMantissa
private

The mantissa value for the floating point number.

◆ m_uMantissaBitCount

uint32_t Burger::FPInfo::m_uMantissaBitCount
private

Number of bits in the mantissa.