diff options
Diffstat (limited to 'src/editfns.c')
-rw-r--r-- | src/editfns.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/editfns.c b/src/editfns.c index 30d585cd018..7d032a7ca4c 100644 --- a/src/editfns.c +++ b/src/editfns.c @@ -47,6 +47,7 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <errno.h> #include <float.h> #include <limits.h> +#include <math.h> #ifdef HAVE_TIMEZONE_T # include <sys/param.h> @@ -4671,6 +4672,12 @@ styled_format (ptrdiff_t nargs, Lisp_Object *args, bool message) { strcpy (f - pMlen - 1, "f"); double x = XFLOAT_DATA (arg); + + /* Truncate and then convert -0 to 0, to be more + consistent with %x etc.; see Bug#31938. */ + x = trunc (x); + x = x ? x : 0; + sprintf_bytes = sprintf (sprintf_buf, convspec, 0, x); char c0 = sprintf_buf[0]; bool signedp = ! ('0' <= c0 && c0 <= '9'); |