37 #ifndef G2O_FAST_OUTPUT_H 38 #define G2O_FAST_OUTPUT_H 52 aux = *end, *end-- = *begin, *begin++ = aux;
55 inline int modp_dtoa(
double value,
char* str,
int prec)
57 static const double pow10[] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
64 if (! (value == value)) {
65 str[0] =
'n'; str[1] =
'a'; str[2] =
'n'; str[3] =
'\0';
70 const double thres_max = (double)(0x7FFFFFFF);
77 }
else if (prec > 9) {
92 int whole = (int) value;
93 double tmp = (value - whole) * pow10[prec];
94 uint32_t frac = (uint32_t)(tmp);
100 if (frac >= pow10[prec]) {
104 }
else if (diff == 0.5 && ((frac == 0) || (frac & 1))) {
116 if (value > thres_max) {
117 return sprintf(str,
"%e", neg ? -value : value);
121 diff = value - whole;
125 }
else if (diff == 0.5 && (whole & 1)) {
135 *wstr++ = (char)(48 + (frac % 10));
136 }
while (frac /= 10);
138 while (count-- > 0) *wstr++ =
'0';
146 do *wstr++ = (char)(48 + (whole % 10));
while (whole /= 10);
159 do *wstr++ = (char)(48 + (value % 10));
while (value /= 10);
170 unsigned int uvalue = (value < 0) ? -value : value;
172 do *wstr++ = (char)(48 + (uvalue % 10));
while(uvalue /= 10);
173 if (value < 0) *wstr++ =
'-';
int modp_uitoa10(uint32_t value, char *str)
int modp_itoa10(int32_t value, char *str)
void strreverse(char *begin, char *end)
int modp_dtoa(double value, char *str, int prec)