From 5906fc6dc9835240e48591e23e3763d8fd98cb5b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mattias=20Engdeg=C3=A5rd?= Date: Thu, 4 Jul 2024 17:48:16 +0200 Subject: [PATCH] ; * src/fns.c (fixnum_float_cmp): Explain argument constraint. Suggested by Pip Cet. (cherry picked from commit fa6f088a483f1f2e19863800c6215a8136288b8f) --- src/fns.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fns.c b/src/fns.c index 07afcada62f..22947b2649f 100644 --- a/src/fns.c +++ b/src/fns.c @@ -3012,16 +3012,18 @@ bool_vector_cmp (Lisp_Object a, Lisp_Object b) return (d & aw) ? 1 : -1; } -/* Return -1 if ab, 0 if a=b or if b is NaN. */ +/* Return -1 if ab, 0 if a=b or if b is NaN (a must be a fixnum). */ static inline int fixnum_float_cmp (EMACS_INT a, double b) { double fa = (double)a; if (fa == b) { - /* This doesn't mean that a=b because the conversion may have - rounded, but b must be an integer that fits in an EMACS_INT - and we can compare in the integer domain instead. */ + /* This doesn't mean that a=b because the conversion may have rounded. + However, b must be an integer that fits in an EMACS_INT, + because |b| ≤ 2|a| and EMACS_INT has at least one bit more than + needed to represent any fixnum. + Thus we can compare in the integer domain instead. */ EMACS_INT ib = b; /* lossless conversion */ return a < ib ? -1 : a > ib; } -- 2.39.2