]> git.eshelyaron.com Git - emacs.git/commit
Compare fixnums and floats accurately in value<
authorMattias EngdegÄrd <mattiase@acm.org>
Thu, 4 Jul 2024 12:46:54 +0000 (14:46 +0200)
committerEshel Yaron <me@eshelyaron.com>
Sun, 7 Jul 2024 13:16:51 +0000 (15:16 +0200)
commit2f7b6a3e4d75760a33e32b7ae65102b8314849fc
tree6c920c682a783f6830444daa93ec6f86a2ba58fc
parent9efbb4ffbd92358f3b3fd9199af6e6f1a1e42cea
Compare fixnums and floats accurately in value<

Make `value<` compare fixnums and floats by value, as `<` does, instead
of coercing the fixnum to a float first which is what C would do.
This matters when the fixnum cannot be represented as a float. For
example, C would evaluate

  72057594037927935 < 72057594037927936.0

to false since the operands are converted to the same floating-point
number.

* src/fns.c (fixnum_float_cmp): New.
(value_cmp): Use it.
* test/src/fns-tests.el (fns-value<-ordered, fns-value<-unordered):
New test cases.

(cherry picked from commit f9f4f054bc15791ff63252e101dbf08bb4eb33c1)
src/fns.c
test/src/fns-tests.el