From 48d6c35548b95d2896ae99217e968a13e985c02b Mon Sep 17 00:00:00 2001 From: Alex Shinn Date: Thu, 2 Jan 2020 22:40:49 +0800 Subject: [PATCH] nans aren't rational --- lib/init-7.scm | 1 + tests/r7rs-tests.scm | 1 + 2 files changed, 2 insertions(+) diff --git a/lib/init-7.scm b/lib/init-7.scm index d631bd30..dc703ab5 100644 --- a/lib/init-7.scm +++ b/lib/init-7.scm @@ -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)))) diff --git a/tests/r7rs-tests.scm b/tests/r7rs-tests.scm index 258cecae..81067c9e 100644 --- a/tests/r7rs-tests.scm +++ b/tests/r7rs-tests.scm @@ -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))