uint64_t al_bl = (a->frac & lomask) * (b->frac & lomask);
uint64_t ah_bh = (a->frac >> 32) * (b->frac >> 32);
- uint64_t tmp = (ah_bl & lomask) + (al_bh & lomask) + (al_bl >> 32);
+ uint64_t tmp = (ah_bl & lomask) + (al_bh & lomask) + (al_bl >> 32);
/* round up */
tmp += 1U << 31;
return generate_digits(&w, &upper, &lower, digits, K);
}
-static int emit_digits(char* digits, int ndigits, char* dest, int K, bool neg)
+static int emit_digits(char* digits, int ndigits, char* dest, int K, bool neg,
+ bool scientific)
{
int exp = absv(K + ndigits - 1);
}
/* write decimal w/o scientific notation */
- if(K < 0 && (K > -7 || exp < 4)) {
+ if(scientific && (K < 0 && (K > -7 || exp < 4))) {
int offset = ndigits - absv(K);
/* fp < 1.0 -> write leading zero */
if(offset <= 0) {
return 3;
}
-int fpconv_dtoa(double d, char dest[24])
+int fpconv_dtoa(double d, char dest[24], bool scientific)
{
char digits[18];
int K = 0;
int ndigits = grisu2(d, digits, &K);
- str_len += emit_digits(digits, ndigits, dest + str_len, K, neg);
+ str_len += emit_digits(digits, ndigits, dest + str_len, K, neg, scientific);
return str_len;
}
case 'f':
- case 'g':
f = (gdouble) va_arg (args, double);
- slen = fpconv_dtoa (f, dtoabuf);
+ slen = fpconv_dtoa (f, dtoabuf, false);
if (frac_width != 0) {
const gchar *dot_pos = memchr (dtoabuf, '.', slen);
continue;
+ case 'g':
+ f = (gdouble) va_arg (args, double);
+ slen = fpconv_dtoa (f, dtoabuf, true);
+ RSPAMD_PRINTF_APPEND (dtoabuf, slen);
+
+ continue;
+
case 'F':
- case 'G':
f = (gdouble) va_arg (args, long double);
- slen = fpconv_dtoa (f, dtoabuf);
+ slen = fpconv_dtoa (f, dtoabuf, false);
if (frac_width != 0) {
const gchar *dot_pos = memchr (dtoabuf, '.', slen);
continue;
+ case 'G':
+ f = (gdouble) va_arg (args, long double);
+ slen = fpconv_dtoa (f, dtoabuf, true);
+ RSPAMD_PRINTF_APPEND (dtoabuf, slen);
+
+ continue;
+
case 'p':
ui64 = (uintptr_t) va_arg (args, void *);
hex = 2;