Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cFloatDeco Class Reference

#include <cFloatDeco.h>

Public Member Functions

 cFloatDeco () noexcept
 
 cFloatDeco (UINT64 uMan, int iExp2) noexcept
 
 cFloatDeco (double d) noexcept
 
cFloatDeco operator- (const cFloatDeco &rhs) const
 
cFloatDeco operator* (const cFloatDeco &rhs) const
 
cFloatDeco Normalize () const
 
void NormalizedBoundaries (cFloatDeco *minus, cFloatDeco *plus) const
 

Static Public Member Functions

static unsigned GetCountDecimalDigit32 (UINT32 n) noexcept
 
static cFloatDeco __stdcall GetCachedPower (int nExp2, OUT int *pnExp10)
 
static double __stdcall toDouble (UINT32 frac1, UINT32 frac2, int nExp10)
 
static void __stdcall GrisuRound (char *pszOut, StrLen_t len, UINT64 delta, UINT64 rest, UINT64 ten_kappa, UINT64 wp_w)
 
static StrLen_t __stdcall Grisu2 (double dVal, char *pszOut, OUT int *pnExp10)
 
static StrLen_t __stdcall MantRound (char *pszOut, StrLen_t nMantLength)
 
static StrLen_t __stdcall MantAdjust (char *pszOut, StrLen_t nMantLength, StrLen_t nMantLengthNew)
 
static StrLen_t __stdcall FormatE (char *pszOut, StrLen_t nMantLength, int nExp10, char chE)
 
static StrLen_t __stdcall FormatF (char *pszOut, StrLen_t nMantLength, int nExp10, int iDecPlacesWanted)
 

Public Attributes

UINT64 m_uMant
 Hold Mantissa. More...
 
int m_iExp2
 Hold base 2 Biased Exponent. More...
 

Static Public Attributes

static const double k_PowersOf10 [9]
 Table giving binary powers of 10. More...
 
static const UINT32 k_Exp10 [10]
 Table of decimal digits to fit in 32 bit space. More...
 
static const UINT64 k_MANT_MASK_X = 0x0010000000000000ULL
 

Detailed Description

holds a decomposed double/float value. ignore sign. Support class for conversion of double/float to string. Used with cFloat64

Constructor & Destructor Documentation

◆ cFloatDeco() [1/3]

Gray::cFloatDeco::cFloatDeco ( )
inlinenoexcept

◆ cFloatDeco() [2/3]

Gray::cFloatDeco::cFloatDeco ( UINT64  uMan,
int  iExp2 
)
inlinenoexcept

◆ cFloatDeco() [3/3]

Gray::cFloatDeco::cFloatDeco ( double  d)
inlinenoexcept

Decompose d.

Member Function Documentation

◆ FormatE()

StrLen_t Gray::cFloatDeco::FormatE ( char *  pszOut,
StrLen_t  nMantLength,
int  nExp10,
char  chE 
)
static

like ecvt() using e exponent.

  • pszOut = string to contains digits.
  • chE = 'e' or 'E'

◆ FormatF()

StrLen_t Gray::cFloatDeco::FormatF ( char *  pszOut,
StrLen_t  nMantLength,
int  nExp10,
int  iDecPlacesWanted 
)
static

like fcvt(). Might be k_LEN_MAX_DIGITS digits long.

  • pszOut contains digits.

◆ GetCachedPower()

cFloatDeco Gray::cFloatDeco::GetCachedPower ( int  nExp2,
OUT int *  pnExp10 
)
static

opposite of k_PowersOf10 10^-348, 10^-340, ..., 10^340, stepped by 8.

◆ GetCountDecimalDigit32()

static unsigned Gray::cFloatDeco::GetCountDecimalDigit32 ( UINT32  n)
inlinestaticnoexcept

How many decimal digits? k_Exp10 Simple C++ implementation is faster than Highest1Bit/__builtin_clz version in this case.

◆ Grisu2()

StrLen_t Gray::cFloatDeco::Grisu2 ( double  dVal,
char *  pszOut,
OUT int *  pnExp10 
)
static

◆ GrisuRound()

void Gray::cFloatDeco::GrisuRound ( char *  pszOut,
StrLen_t  len,
UINT64  delta,
UINT64  rest,
UINT64  ten_kappa,
UINT64  wp_w 
)
static

Round last digit down?

◆ MantAdjust()

StrLen_t Gray::cFloatDeco::MantAdjust ( char *  pszOut,
StrLen_t  nMantLength,
StrLen_t  nMantLengthNew 
)
static

Change mantissa size up or down.

Returns
size change.

◆ MantRound()

StrLen_t Gray::cFloatDeco::MantRound ( char *  pszOut,
StrLen_t  nMantLength 
)
static

◆ Normalize()

cFloatDeco Gray::cFloatDeco::Normalize ( ) const
inline

Fix m_iExp2 by making m_uMant as large as possible. cBits::Highest1Bit<>

◆ NormalizedBoundaries()

void Gray::cFloatDeco::NormalizedBoundaries ( cFloatDeco minus,
cFloatDeco plus 
) const
inline

◆ operator*()

cFloatDeco Gray::cFloatDeco::operator* ( const cFloatDeco rhs) const
inline

Do math on decomposed numbers.

mult_round

◆ operator-()

cFloatDeco Gray::cFloatDeco::operator- ( const cFloatDeco rhs) const
inline

Do math on decomposed number. ASSUME same m_iExp2

◆ toDouble()

double GRAYCALL Gray::cFloatDeco::toDouble ( UINT32  frac1,
UINT32  frac2,
int  nExp10 
)
static

Member Data Documentation

◆ k_Exp10

const UINT32 Gray::cFloatDeco::k_Exp10
static
Initial value:
=
{
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000
}

Table of decimal digits to fit in 32 bit space.

◆ k_MANT_MASK_X

const UINT64 Gray::cFloatDeco::k_MANT_MASK_X = 0x0010000000000000ULL
static

◆ k_PowersOf10

const double Gray::cFloatDeco::k_PowersOf10
static
Initial value:
=
{
10.0,
100.0,
1.0e4,
1.0e8,
1.0e16,
1.0e32,
1.0e64,
1.0e128,
1.0e256
}

Table giving binary powers of 10.

◆ m_iExp2

int Gray::cFloatDeco::m_iExp2

Hold base 2 Biased Exponent.

◆ m_uMant

UINT64 Gray::cFloatDeco::m_uMant

Hold Mantissa.


The documentation for this class was generated from the following files: