25#ifndef __DCONV_GRISU2_HPP__
26#define __DCONV_GRISU2_HPP__
50 w.normalizedBoundaries (minus, plus);
68 inline void round (
char* buffer,
int length, uint64_t delta, uint64_t rest, uint64_t tenKappa,
69 uint64_t wpW)
noexcept
71 while ((rest < wpW && delta - rest >= tenKappa) &&
72 (rest + tenKappa < wpW || wpW - rest > rest + tenKappa - wpW))
91 const DiyFp one (
static_cast<uint64_t
> (1) << -high._exponent, high._exponent);
92 const DiyFp wpW = high - w;
93 uint32_t p1 =
static_cast<uint32_t
> (high._mantissa >> -one.
_exponent);
100 assert (kappa >= 1 && kappa <= 10);
105 buffer[length++] =
'0' + d;
108 uint64_t rest = (
static_cast<uint64_t
> (p1) << -one.
_exponent) + p2;
121 assert (unit <= UINT64_MAX / 10);
125 char d =
static_cast<char> (p2 >> -one.
_exponent);
126 buffer[length] =
'0' + d;
127 length += (d || length);
146 inline void generate (
char* buffer,
int& length,
int& k,
double value)
noexcept
148 DiyFp w, minus, plus;
163 inline char*
dtoa (
char* buffer,
double value)
noexcept
hand made floating point.
Definition diyfp.hpp:41
constexpr DiyFp & normalize() noexcept
normalize floating point.
Definition diyfp.hpp:104
uint64_t _mantissa
mantissa.
Definition diyfp.hpp:223
int _exponent
exponent.
Definition diyfp.hpp:226
constexpr uint32_t pow10[]
powers of ten that fit in 32 bits.
Definition digits.hpp:36
int countDigits(uint64_t digits) noexcept
count the digits of a decimal significand.
Definition digits.hpp:64
char * dtoa(char *buffer, double value) noexcept
double to string conversion using Grisu2.
Definition grisu2.hpp:163
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.
Definition grisu2.hpp:68
void scaledBoundaries(double value, DiyFp &w, DiyFp &minus, DiyFp &plus, int &k) noexcept
compute the scaled value and its scaled boundaries.
Definition grisu2.hpp:47
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.
Definition grisu2.hpp:88
void generate(char *buffer, int &length, int &k, double value) noexcept
write the shortest decimal digits within the conservative boundaries.
Definition grisu2.hpp:146
char * dtoa(char *buffer, double value, void(*generate)(char *, int &, int &, double) noexcept) noexcept
double to string conversion with the given digits generator.
Definition grisu.hpp:50
const DiyFp & cachedPower(int exponent, int &k) noexcept
get the cached power of ten that scales a binary exponent into the digit generation range.
Definition grisu.hpp:79