summaryrefslogtreecommitdiff
path: root/src/bytecode.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2017-03-02 09:11:11 -0800
committerPaul Eggert <eggert@cs.ucla.edu>2017-03-02 09:12:49 -0800
commit4e2622bf0d63c40f447d44e6401ea054ef55b261 (patch)
tree10f66df3cd59695ffe15546aaa961987a3fe2ba1 /src/bytecode.c
parentd546be31a9320d94769cb322f008f49d08d852a8 (diff)
downloademacs-4e2622bf0d63c40f447d44e6401ea054ef55b261.tar.gz
emacs-4e2622bf0d63c40f447d44e6401ea054ef55b261.tar.bz2
emacs-4e2622bf0d63c40f447d44e6401ea054ef55b261.zip
Fix rounding errors in <, =, etc.
* etc/NEWS: Document this. * src/bytecode.c (exec_byte_code): * src/data.c (arithcompare): Do not lose information when comparing floats to integers. * test/src/data-tests.el (data-tests-=, data-tests-<) (data-tests->, data-tests-<=, data-tests->=): Test this.
Diffstat (limited to 'src/bytecode.c')
-rw-r--r--src/bytecode.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/bytecode.c b/src/bytecode.c
index 4414b077bb9..e781a87d16f 100644
--- a/src/bytecode.c
+++ b/src/bytecode.c
@@ -992,18 +992,14 @@ exec_byte_code (Lisp_Object bytestr, Lisp_Object vector, Lisp_Object maxdepth,
CASE (Beqlsign):
{
Lisp_Object v2 = POP, v1 = TOP;
- CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1);
- CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2);
- bool equal;
if (FLOATP (v1) || FLOATP (v2))
+ TOP = arithcompare (v1, v2, ARITH_EQUAL);
+ else
{
- double f1 = FLOATP (v1) ? XFLOAT_DATA (v1) : XINT (v1);
- double f2 = FLOATP (v2) ? XFLOAT_DATA (v2) : XINT (v2);
- equal = f1 == f2;
+ CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v1);
+ CHECK_NUMBER_OR_FLOAT_COERCE_MARKER (v2);
+ TOP = EQ (v1, v2) ? Qt : Qnil;
}
- else
- equal = XINT (v1) == XINT (v2);
- TOP = equal ? Qt : Qnil;
NEXT;
}