dconv 2.0
C++14 library for printing and parsing floating point numbers
Loading...
Searching...
No Matches
dconv::schubfach Namespace Reference

Functions

constexpr int floorLog10Pow2 (int q, bool asymmetric) noexcept
 compute floor (log10 (2^q)) or floor (log10 (3/4 * 2^q)).
 
constexpr int floorLog2Pow10 (int k) noexcept
 compute floor (log2 (10^k)).
 
uint64_t roundToOdd (const details::Power &g, uint64_t cp) noexcept
 multiply by a power of ten and round to odd.
 
uint64_t shortest (double value, int &k) noexcept
 compute the shortest decimal significand.
 
void generate (char *buffer, int &length, int &k, double value) noexcept
 write the shortest decimal digits.
 
char * dtoa (char *buffer, double value) noexcept
 double to string conversion using Schubfach.
 

Function Documentation

◆ dtoa()

char * dconv::schubfach::dtoa ( char * buffer,
double value )
inlinenoexcept

double to string conversion using Schubfach.

Parameters
bufferbuffer to write the string representation to (must point to at least 25 writable bytes).
valuevalue to convert.
Returns
end position.

◆ floorLog10Pow2()

int dconv::schubfach::floorLog10Pow2 ( int q,
bool asymmetric )
constexprnoexcept

compute floor (log10 (2^q)) or floor (log10 (3/4 * 2^q)).

Parameters
qbinary exponent.
asymmetriccompute floor (log10 (3/4 * 2^q)) if true.
Returns
decimal exponent.

◆ floorLog2Pow10()

int dconv::schubfach::floorLog2Pow10 ( int k)
constexprnoexcept

compute floor (log2 (10^k)).

Parameters
kdecimal exponent.
Returns
binary exponent.

◆ generate()

void dconv::schubfach::generate ( char * buffer,
int & length,
int & k,
double value )
inlinenoexcept

write the shortest decimal digits.

Parameters
bufferbuffer to write the digits to.
lengthnumber of digits written.
kdecimal exponent.
valuepositive value to convert.

◆ roundToOdd()

uint64_t dconv::schubfach::roundToOdd ( const details::Power & g,
uint64_t cp )
inlinenoexcept

multiply by a power of ten and round to odd.

Parameters
gpower of ten.
cpvalue to multiply.
Returns
product rounded to odd.

◆ shortest()

uint64_t dconv::schubfach::shortest ( double value,
int & k )
inlinenoexcept

compute the shortest decimal significand.

Parameters
valuepositive value to convert.
kdecimal exponent.
Returns
decimal significand, possibly with trailing zeros.