mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
fix rational? for some boundary cases
This commit is contained in:
parent
a9f9b3dd8a
commit
c174465aa1
2 changed files with 7 additions and 1 deletions
|
@ -1375,7 +1375,10 @@
|
||||||
(complex (define (real? x) (and (number? x) (not (%complex? x)))))
|
(complex (define (real? x) (and (number? x) (not (%complex? x)))))
|
||||||
(else (define real? number?)))
|
(else (define real? number?)))
|
||||||
(define (rational? x)
|
(define (rational? x)
|
||||||
(and (real? x) (= x x) (not (= x (+ x (if (positive? x) 1 -1))))))
|
(and (real? x)
|
||||||
|
(if (or (> x 1) (< x -1))
|
||||||
|
(not (= x (/ x 2)))
|
||||||
|
(<= -1 x 1))))
|
||||||
|
|
||||||
(define (eqv? a b) (if (eq? a b) #t (and (number? a) (equal? a b))))
|
(define (eqv? a b) (if (eq? a b) #t (and (number? a) (equal? a b))))
|
||||||
|
|
||||||
|
|
|
@ -749,6 +749,9 @@
|
||||||
(test #t (real? #e1e10))
|
(test #t (real? #e1e10))
|
||||||
(test #t (real? +inf.0))
|
(test #t (real? +inf.0))
|
||||||
(test #f (rational? -inf.0))
|
(test #f (rational? -inf.0))
|
||||||
|
(test #t (rational? 9007199254740991.0))
|
||||||
|
(test #t (rational? 9007199254740992.0))
|
||||||
|
(test #t (rational? 1.7976931348623157e308))
|
||||||
(test #t (rational? 6/10))
|
(test #t (rational? 6/10))
|
||||||
(test #t (rational? 6/3))
|
(test #t (rational? 6/3))
|
||||||
(test #t (integer? 3+0i))
|
(test #t (integer? 3+0i))
|
||||||
|
|
Loading…
Add table
Reference in a new issue