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

Functions

void scaledBoundaries (double value, DiyFp &w, DiyFp &minus, DiyFp &plus, int &k) noexcept
 compute the scaled value and its scaled boundaries.
 
void round (char *buffer, int length, uint64_t delta, uint64_t rest, uint64_t tenKappa, uint64_t wpW) noexcept
 move the last digit closer to the value while it stays within the boundaries.
 
void digitsGen (const DiyFp &w, const DiyFp &high, uint64_t delta, char *buffer, int &length, int &k) noexcept
 generate the shortest digits within the conservative boundaries.
 
void generate (char *buffer, int &length, int &k, double value) noexcept
 write the shortest decimal digits within the conservative boundaries.
 
char * dtoa (char *buffer, double value) noexcept
 double to string conversion using Grisu2.
 

Function Documentation

◆ digitsGen()

void dconv::grisu2::digitsGen ( const DiyFp & w,
const DiyFp & high,
uint64_t delta,
char * buffer,
int & length,
int & k )
inlinenoexcept

generate the shortest digits within the conservative boundaries.

Parameters
wscaled value.
highconservative upper boundary.
deltadistance between the conservative boundaries.
bufferbuffer to write the digits to.
lengthnumber of digits written.
kdecimal exponent.

◆ dtoa()

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

double to string conversion using Grisu2.

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

◆ generate()

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

write the shortest decimal digits within the conservative boundaries.

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

◆ round()

void dconv::grisu2::round ( char * buffer,
int length,
uint64_t delta,
uint64_t rest,
uint64_t tenKappa,
uint64_t wpW )
inlinenoexcept

move the last digit closer to the value while it stays within the boundaries.

Parameters
buffergenerated digits.
lengthnumber of generated digits.
deltadistance between the boundaries.
restdistance between the upper boundary and the generated number.
tenKappascaled power of ten of the last digit.
wpWdistance between the upper boundary and the value.

◆ scaledBoundaries()

void dconv::grisu2::scaledBoundaries ( double value,
DiyFp & w,
DiyFp & minus,
DiyFp & plus,
int & k )
inlinenoexcept

compute the scaled value and its scaled boundaries.

Parameters
valuepositive value to convert.
wscaled value.
minusscaled lower boundary.
plusscaled upper boundary.
kdecimal exponent of the scaled values.