nans aren't rational

This commit is contained in:
Alex Shinn 2020-01-02 22:40:49 +08:00
parent c174465aa1
commit 48d6c35548
2 changed files with 2 additions and 0 deletions

View file

@ -1376,6 +1376,7 @@
(else (define real? number?)))
(define (rational? x)
(and (real? x)
(= x x)
(if (or (> x 1) (< x -1))
(not (= x (/ x 2)))
(<= -1 x 1))))

View file

@ -749,6 +749,7 @@
(test #t (real? #e1e10))
(test #t (real? +inf.0))
(test #f (rational? -inf.0))
(test #f (rational? +nan.0))
(test #t (rational? 9007199254740991.0))
(test #t (rational? 9007199254740992.0))
(test #t (rational? 1.7976931348623157e308))