Kicking it Olde Sküül! Burgerlib on Github Follow Olde Sküül on Twitter Burgerbecky on LinkedIn Burgerbecky on LinkedIn
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Attributes | Private Types | Private Attributes | List of all members
Burger::FPPrintInfo Class Reference

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_infinity (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.
 

Detailed Description

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.

We also support optional significant digit cutoff, in order to emulate RTLs that quit after a set number of digits (looking at you Microsoft)

Member Enumeration Documentation

◆ eResult

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.

Enumerator
kResultZero 

Print a zero.

kResultNormalFloat 

Print a normal number.

kResultFloatRoundedUpAtEnd 

Print a number that is rounded in the fraction.

kResultFloatRoundedUpADigit 

Print a number that is rounded in the integer.

kResultPositiveInfinity 

Print a positive infinity.

kResultNegativeInfinity 

Print a negative infinity.

kResultPositiveNaN 

Print a positive NaN.

kResultNegativeNaN 

Print a negative NaN.

kResultSignalingNaN 

Print a signaling NaN.

kResultQuietNaN 

Print a quiet NaN.

kResultIndefiniteNaN 

Print an indefinite NaN.

kResultCount 

End of print list.

kResultFirstSpecial 

First special string to print.

kResultLastSpecial 

Last special string to print.

◆ eTextIndex

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.

Constructor & Destructor Documentation

◆ FPPrintInfo() [1/2]

Burger::FPPrintInfo::FPPrintInfo ( void )
inlinenoexcept

Default constructor.


Clear out the variables and set the data to zero

◆ FPPrintInfo() [2/2]

Burger::FPPrintInfo::FPPrintInfo ( const FPInfo * pFPInfo,
uint32_t uPrecisionDigits )
inlinenoexcept

Construct with input data.


Parameters
pFPInfoPointer to the floating point number to analyze
uPrecisionDigitsNumber of digits of precision to print
See also
analyze_float(const FPInfo*, uint32_t)

Member Function Documentation

◆ analyze_float()

void BURGER_API Burger::FPPrintInfo::analyze_float ( const FPInfo * pFPInfo,
uint32_t uPrecisionDigits )
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.

Parameters
pFPInfoPointer to the floating point number to analyze
uPrecisionDigitsNumber of digits of precision to print

◆ clear()

void BURGER_API Burger::FPPrintInfo::clear ( void )
noexcept

Reset the class.


Clear out the variables and set the data to zero

◆ get_first_non_zero_frac_digit_position()

Burger::FPPrintInfo::get_first_non_zero_frac_digit_position ( void ) const
inlinenoexcept

Get the index to the first fractional digit.


Returns
The index to the first fractional digit

◆ get_first_non_zero_int_digit_position()

Burger::FPPrintInfo::get_first_non_zero_int_digit_position ( void ) const
inlinenoexcept

Get the index to the first integer digit.


Returns
The index to the first integer digit

◆ get_last_non_zero_frac_digit_position()

Burger::FPPrintInfo::get_last_non_zero_frac_digit_position ( void ) const
inlinenoexcept

Get the index to the last fractional digit.


Returns
The index to the last fractional digit

◆ get_last_non_zero_int_digit_position()

Burger::FPPrintInfo::get_last_non_zero_int_digit_position ( void ) const
inlinenoexcept

Get the index to the last integer digit.


Returns
The index to the last integer digit

◆ get_result()

Burger::FPPrintInfo::get_result ( void ) const
inlinenoexcept

Get the type of number to print.


Returns
The type of number that should be printed.

◆ get_special_form_digits()

Burger::FPPrintInfo::get_special_form_digits ( void ) const
inlinenoexcept

Get the number of special form digits.


Returns
The number of special form digits

◆ has_fractional()

Burger::FPPrintInfo::has_fractional ( void ) const
inlinenoexcept

Does the string have a fractional part?


Returns
TRUE if there are fractional digits

◆ has_integer()

Burger::FPPrintInfo::has_integer ( void ) const
inlinenoexcept

Does the string have an integer part?


Returns
TRUE if there are integer digits

◆ is_infinity()

Burger::FPPrintInfo::is_infinity ( void ) const
inlinenoexcept

Is the number infinity?


Returns
TRUE if the number is INF

◆ is_NaN()

Burger::FPPrintInfo::is_NaN ( void ) const
inlinenoexcept

Is the number Not a Number?


Returns
TRUE if the number is NaN

◆ is_special()

Burger::FPPrintInfo::is_special ( void ) const
inlinenoexcept

Is the number a special?


Returns
TRUE if the number is NaN/INF

Member Data Documentation

◆ g_SpecialFloatsTextLower

const char * Burger::FPPrintInfo::g_SpecialFloatsTextLower
static
Initial value:
= {
"inf", "-inf", "nan", "-nan", "-nan"}

Special float message strings.

◆ g_SpecialFloatsTextUpper

const char * Burger::FPPrintInfo::g_SpecialFloatsTextUpper
static
Initial value:
= {
"INF", "-INF", "NAN", "-NAN", "-NAN"}

Special float message string in uppercase.

◆ m_bHasFractionalPart

uint_t Burger::FPPrintInfo::m_bHasFractionalPart
private

TRUE if there is a fractional component

◆ m_bHasIntegerPart

uint_t Burger::FPPrintInfo::m_bHasIntegerPart
private

TRUE if there is an integer component

◆ m_uFirstNonZeroFracDigitPos

uint32_t Burger::FPPrintInfo::m_uFirstNonZeroFracDigitPos
private

Index to the first non zero fractional digit.

◆ m_uFirstNonZeroIntDigitPos

uint32_t Burger::FPPrintInfo::m_uFirstNonZeroIntDigitPos
private

Index to the first non zero integer digit.

◆ m_uLastNonZeroFracDigitPos

uint32_t Burger::FPPrintInfo::m_uLastNonZeroFracDigitPos
private

Index to the last non zero integer digit.

◆ m_uLastNonZeroIntDigitPos

uint32_t Burger::FPPrintInfo::m_uLastNonZeroIntDigitPos
private

Index to the last non zero integer digit.

◆ m_uPrintResult

eResult Burger::FPPrintInfo::m_uPrintResult
private

Type of floating point number.

◆ m_uSpecialFormDigits

uint32_t Burger::FPPrintInfo::m_uSpecialFormDigits
private

Number of digits for special text.