diff options
| author | Mattias EngdegÄrd | 2024-07-04 14:46:54 +0200 |
|---|---|---|
| committer | Mattias EngdegÄrd | 2024-07-04 15:32:45 +0200 |
| commit | f9f4f054bc15791ff63252e101dbf08bb4eb33c1 (patch) | |
| tree | 54413cfb6d646fb526c82ea3f91fa207a34b1593 /test/src/fns-tests.el | |
| parent | 565f4e4ad17c929159d646bfeff7d1adb4c9b727 (diff) | |
| download | emacs-f9f4f054bc15791ff63252e101dbf08bb4eb33c1.tar.gz emacs-f9f4f054bc15791ff63252e101dbf08bb4eb33c1.zip | |
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.
Diffstat (limited to 'test/src/fns-tests.el')
| -rw-r--r-- | test/src/fns-tests.el | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/src/fns-tests.el b/test/src/fns-tests.el index ca5b10db705..8d39a1a56b8 100644 --- a/test/src/fns-tests.el +++ b/test/src/fns-tests.el | |||
| @@ -1606,6 +1606,13 @@ | |||
| 1606 | (1.5 . 1.6) (-1.3 . -1.2) (-13.0 . 12.0) | 1606 | (1.5 . 1.6) (-1.3 . -1.2) (-13.0 . 12.0) |
| 1607 | ;; floats/fixnums | 1607 | ;; floats/fixnums |
| 1608 | (1 . 1.1) (1.9 . 2) (-2.0 . 1) (-2 . 1.0) | 1608 | (1 . 1.1) (1.9 . 2) (-2.0 . 1) (-2 . 1.0) |
| 1609 | ;; fixnums that can't be represented as floats | ||
| 1610 | (72057594037927935 . 72057594037927936.0) | ||
| 1611 | (72057594037927936.0 . 72057594037927937) | ||
| 1612 | (-72057594037927936.0 . -72057594037927935) | ||
| 1613 | (-72057594037927937 . -72057594037927936.0) | ||
| 1614 | (2305843009213693951 . 2305843009213693952.0) | ||
| 1615 | |||
| 1609 | ;; floats/bignums | 1616 | ;; floats/bignums |
| 1610 | (,big . ,(float (* 2 big))) (,(float big) . ,(* 2 big)) | 1617 | (,big . ,(float (* 2 big))) (,(float big) . ,(* 2 big)) |
| 1611 | ;; symbols | 1618 | ;; symbols |
| @@ -1683,6 +1690,9 @@ | |||
| 1683 | ;; numbers | 1690 | ;; numbers |
| 1684 | (0 . 0.0) (0 . -0.0) (0.0 . -0.0) | 1691 | (0 . 0.0) (0 . -0.0) (0.0 . -0.0) |
| 1685 | 1692 | ||
| 1693 | (72057594037927936 . 72057594037927936.0) | ||
| 1694 | (1 . 0.0e+NaN) | ||
| 1695 | |||
| 1686 | ;; symbols | 1696 | ;; symbols |
| 1687 | (a . #:a) | 1697 | (a . #:a) |
| 1688 | 1698 | ||