From f67f63d570c42db6f32eaa1d036d87220cc6b9b6 Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Sun, 1 Apr 2018 21:01:58 +0900 Subject: [PATCH] fixing number->string for numbers within an ulp of round numbers --- sexp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sexp.c b/sexp.c index 94d1d096..39475a27 100644 --- a/sexp.c +++ b/sexp.c @@ -1931,9 +1931,9 @@ sexp sexp_write_one (sexp ctx, sexp obj, sexp out) { #endif { i = snprintf(numbuf, NUMBUF_LEN, "%.15lg", f); - if (i >= 15 && sscanf(numbuf, "%lg", &ftmp) == 1 && ftmp != f) { + if (sscanf(numbuf, "%lg", &ftmp) == 1 && ftmp != f) { i = snprintf(numbuf, NUMBUF_LEN, "%.16lg", f); - if (i >= 16 && sscanf(numbuf, "%lg", &ftmp) == 1 && ftmp != f) { + if (sscanf(numbuf, "%lg", &ftmp) == 1 && ftmp != f) { i = snprintf(numbuf, NUMBUF_LEN, "%.17lg", f); } }