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. | |
FPInfo & | operator= (uint16_t usValue) noexcept |
Process a 16 bit floating point number. | |
FPInfo & | operator= (float fValue) noexcept |
Process a 32 bit floating point number. | |
FPInfo & | operator= (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. | |
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.
|
explicitnoexcept |
Default constructor.
All values are set to zero. Use the Init() functions or assignment operators to perform floating point analysis.
|
explicitnoexcept |
Constructor for 16 bit float.
uValue | 16 bit floating point number |
|
explicitnoexcept |
Constructor for 32 bit float.
fValue | 32 bit floating point number |
|
explicitnoexcept |
Constructor for 64 bit float.
dValue | 64 bit floating point number |
|
inlinenoexcept |
Get the biased exponent.
|
inlinenoexcept |
Get the exponent.
Returns the exponent as it was meant to be represented, as such, it's a signed integer.
|
inlinenoexcept |
Get the number of bits in the exponent.
|
inlinenoexcept |
Get the mantissa value.
|
inlinenoexcept |
Get the number of bits in the mantissa.
|
noexcept |
Process a 64 bit floating point number.
Given a 64 bit floating point number, process it into its component parts.
dValue | 64 bit float point number |
|
noexcept |
Process a 32 bit floating point number.
Given a 32 bit floating point number, process it into its component parts.
fValue | 32 bit float point number |
|
noexcept |
Process a 16 bit floating point number.
Given a 16 bit floating point number, process it into its component parts.
uValue | 16 bit float point number |
|
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.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Detect if a number is Not a Number.
This returns TRUE for all forms of Not a Number.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Process a 64 bit floating point number.
Given a 64 bit floating point number, process it into its component parts.
dValue | 64 bit float point number |
|
inlinenoexcept |
Process a 32 bit floating point number.
Given a 32 bit floating point number, process it into its component parts.
fValue | 32 bit float point number |
|
inlinenoexcept |
Process a 16 bit floating point number.
Given a 16 bit floating point number, process it into its component parts.
usValue | 16 bit float point number |
|
staticconstexprprivate |
Bias of the exponent for a 16 bit float.
|
staticconstexprprivate |
Bias of the exponent for a 32 bit float.
|
staticconstexprprivate |
Bias of the exponent for a 64 bit float.
|
staticconstexprprivate |
Number of bits in the exponent for a 16 bit float.
|
staticconstexprprivate |
Number of bits in the exponent for a 32 bit float.
|
staticconstexprprivate |
Number of bits in the exponent for a 64 bit float.
|
staticconstexprprivate |
Mask for the exponent in a 16 bit float.
|
staticconstexprprivate |
Mask for the exponent in a 32 bit float.
|
staticconstexprprivate |
Mask for the exponent in a 64 bit float.
|
staticconstexprprivate |
Flag that's set if the number is an unknown "Not a Number".
|
staticconstexprprivate |
Flag that's set if the number is infinite.
|
staticconstexprprivate |
Flag that's set if the number is a "Not a Number".
|
staticconstexprprivate |
Flag that's set if the number is negative.
|
staticconstexprprivate |
Flag that's set if the number is a quiet "Not a Number".
|
staticconstexprprivate |
Flag that's set if the number is not normalized.
|
staticconstexprprivate |
Flag that's set if a floating point number was analyzed.
|
staticconstexprprivate |
Flag that's set if the number is zero.
|
staticconstexprprivate |
Implicit "1" bit for a 16 bit float.
|
staticconstexprprivate |
Implicit "1" bit for a 32 bit float.
|
staticconstexprprivate |
Implicit "1" bit for a 64 bit float.
|
staticconstexprprivate |
Number of bits in the mantissa for a 16 bit float.
|
staticconstexprprivate |
Number of bits in the mantissa for a 32 bit float.
|
staticconstexprprivate |
Number of bits in the mantissa for a 64 bit float.
|
staticconstexprprivate |
Mask for the mantissa in a 16 bit float.
|
staticconstexprprivate |
Mask for the mantissa in a 32 bit float.
|
staticconstexprprivate |
Mask for the mantissa in a 64 bit float.
|
staticconstexprprivate |
QNAN or SNAN bit in a 16 bit float.
|
staticconstexprprivate |
QNAN or SNAN bit in a 32 bit float.
|
staticconstexprprivate |
QNAN or SNAN bit in a 64 bit float.
|
staticconstexprprivate |
Location of the sign bit in a 16 bit float.
|
staticconstexprprivate |
Location of the sign bit in a 32 bit float.
|
staticconstexprprivate |
Location of the sign bit in a 64 bit float.
|
staticconstexprprivate |
Special exponent for INF/NAN in a 16 bit float.
|
staticconstexprprivate |
Special exponent for INF/NAN in a 32 bit float.
|
staticconstexprprivate |
Special exponent for INF/NAN in a 64 bit float.
|
private |
Exponent with bias applied.
|
private |
Exponent as stored in the floating point number.
|
private |
Number of bits in the exponent.
|
private |
Flags that contain the determined states.
|
private |
The mantissa value for the floating point number.
|
private |
Number of bits in the mantissa.