Digit printing class for floating point. More...
Public Types | |
enum | eResult { kResultZero , kResultNormalFloat , kResultFloatRoundedUpAtEnd , kResultFloatRoundedUpADigit , kResultPositiveInfinity , kResultNegativeInfinity , kResultPositiveNaN , kResultNegativeNaN , kResultSignalingNaN , kResultQuietNaN , kResultIndefiniteNaN , kResultCount , kResultFirstSpecial = kResultPositiveInfinity , kResultLastSpecial = kResultIndefiniteNaN } |
Detected floating point number. More... |
Public Member Functions | |
FPPrintInfo (void) noexcept | |
Default constructor. | |
FPPrintInfo (const FPInfo *pFPInfo, uint32_t uPrecisionDigits) noexcept | |
Construct with input data. | |
void | clear (void) noexcept |
Reset the class. | |
uint_t | has_integer (void) const noexcept |
Does the string have an integer part? | |
uint_t | has_fractional (void) const noexcept |
Does the string have a fractional part? | |
uint32_t | get_special_form_digits (void) const noexcept |
Get the number of special form digits. | |
uint32_t | get_first_non_zero_int_digit_position (void) const noexcept |
Get the index to the first integer digit. | |
uint32_t | get_last_non_zero_int_digit_position (void) const noexcept |
Get the index to the last integer digit. | |
uint32_t | get_first_non_zero_frac_digit_position (void) const noexcept |
Get the index to the first fractional digit. | |
uint32_t | get_last_non_zero_frac_digit_position (void) const noexcept |
Get the index to the last fractional digit. | |
eResult | get_result (void) const noexcept |
Get the type of number to print. | |
uint_t | is_special (void) const noexcept |
Is the number a special? | |
uint_t | is_infinite (void) const noexcept |
Is the number infinity? | |
uint_t | is_NaN (void) const noexcept |
Is the number Not a Number? | |
void | analyze_float (const FPInfo *pFPInfo, uint32_t uPrecisionDigits) noexcept |
Analyze a floating point number. |
Static Public Attributes | |
static const char * | g_SpecialFloatsTextLower [kTextCount] |
Special float message strings. | |
static const char * | g_SpecialFloatsTextUpper [kTextCount] |
Special float message string in uppercase. |
Private Types | |
enum | eTextIndex { kPosInfinity , kNegInfinity , kPosNan , kNegNan , kIndNan , kTextCount } |
Indexes for special floating point number names. More... |
Private Attributes | |
uint_t | m_bHasIntegerPart |
TRUE if there is an integer component | |
uint_t | m_bHasFractionalPart |
TRUE if there is a fractional component | |
uint32_t | m_uSpecialFormDigits |
Number of digits for special text. | |
uint32_t | m_uFirstNonZeroIntDigitPos |
Index to the first non zero integer digit. | |
uint32_t | m_uLastNonZeroIntDigitPos |
Index to the last non zero integer digit. | |
uint32_t | m_uFirstNonZeroFracDigitPos |
Index to the first non zero fractional digit. | |
uint32_t | m_uLastNonZeroFracDigitPos |
Index to the last non zero integer digit. | |
eResult | m_uPrintResult |
Type of floating point number. |
Digit printing class for floating point.
Analyze the floating point number. Determine if it is a 'special' form and where the digits start and end on each side of the decimal point. It is used to determine exactly how the final result of the string would be for the floating point number in question. With this information, a floating point number can be printed at any precision.
It also supports optional significant digit cutoff, in order to emulate run time libraries that quit after a set number of digits (looking at you Microsoft)
Detected floating point number.
After parsing a floating point number for printing, this enumeration is one of the many types of output that the final result will be.
|
private |
Indexes for special floating point number names.
In the tables g_SpecialFloatsTextLower and g_SpecialFloatsTextUpper, the names of the special case floating point numbers are stored and the names are in the order of this enumeration.
Enumerator | |
---|---|
kPosInfinity | Index to "inf". |
kNegInfinity | Index to "-inf". |
kPosNan | Index to "nan". |
kNegNan | Index to "-nan". |
kIndNan | Index to "-nan". |
kTextCount | Number of string indexes. |
|
inlinenoexcept |
Default constructor.
Clear out the variables and set the data to zero
|
inlinenoexcept |
Construct with input data.
pFPInfo | Pointer to the floating point number to analyze |
uPrecisionDigits | Number of digits of precision to print |
|
noexcept |
Analyze a floating point number.
Analyze the floating point number. Determine if it is a 'special' form and where the digits start and end on each side of the decimal point.
pFPInfo | Pointer to the floating point number to analyze |
uPrecisionDigits | Number of digits of precision to print |
|
noexcept |
Reset the class.
Clear out the variables and set the data to zero
|
inlinenoexcept |
Get the index to the first fractional digit.
|
inlinenoexcept |
Get the index to the first integer digit.
|
inlinenoexcept |
Get the index to the last fractional digit.
|
inlinenoexcept |
Get the index to the last integer digit.
|
inlinenoexcept |
Get the type of number to print.
|
inlinenoexcept |
Get the number of special form digits.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
static |
Special float message strings.
|
static |
Special float message string in uppercase.
|
private |
Index to the first non zero fractional digit.
|
private |
Index to the first non zero integer digit.
|
private |
Index to the last non zero integer digit.
|
private |
Index to the last non zero integer digit.
|
private |
Type of floating point number.
|
private |
Number of digits for special text.