summaryrefslogtreecommitdiffstats
path: root/src/libutil
diff options
context:
space:
mode:
authorVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-23 13:47:58 +0000
committerVsevolod Stakhov <vsevolod@highsecure.ru>2018-03-23 13:47:58 +0000
commitc3eb6a173e5076a19ad1cf03653b8cc6b610e2c5 (patch)
tree62a39803532363816f5eb7f8444473aa6504466c /src/libutil
parent0e14312dc263b8712e4c840d8eaebe313ef9d93f (diff)
downloadrspamd-c3eb6a173e5076a19ad1cf03653b8cc6b610e2c5.tar.gz
rspamd-c3eb6a173e5076a19ad1cf03653b8cc6b610e2c5.zip
[Fix] Add rounding when printing a lot of FP variables
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/str_util.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/libutil/str_util.c b/src/libutil/str_util.c
index 570f9a948..8026ea7e5 100644
--- a/src/libutil/str_util.c
+++ b/src/libutil/str_util.c
@@ -1910,16 +1910,14 @@ static int
rspamd_fstring_emit_append_double (double val, void *ud)
{
rspamd_fstring_t **buf = ud;
- const double delta = 0.0000001;
+#define MAX_PRECISION 6
if (isfinite (val)) {
if (val == (double) ((gint) val)) {
rspamd_printf_fstring (buf, "%.1f", val);
- } else if (fabs (val - (double) (int) val) < delta) {
- /* Write at maximum precision */
- rspamd_printf_fstring (buf, "%.*g", DBL_DIG, val);
} else {
- rspamd_printf_fstring (buf, "%f", val);
+ rspamd_printf_fstring (buf, "%." G_STRINGIFY (MAX_PRECISION) "f",
+ val);
}
}
else {