x
(flo:/ (rat:->inexact x) y)))
(else ((copy rat:/) x y))))
+
+(define (real:eqv? x y)
+ (if (flonum? x)
+ (and (flonum? y)
+ (flo:eqv? x y))
+ (and (not (flonum? y))
+ ;; Both are exact, so RAT:= will DTRT.
+ ((copy rat:=) x y))))
\f
(define (real:= x y)
(if (flonum? x)
(error:wrong-type-argument x #f name))
(rec:real-part x))
+(define (complex:eqv? z1 z2)
+ (if (recnum? z1)
+ (if (recnum? z2)
+ (and (real:eqv? (rec:real-part z1) (rec:real-part z2))
+ (real:eqv? (rec:imag-part z1) (rec:imag-part z2)))
+ (and (real:exact0= (rec:imag-part z1))
+ (real:eqv? (rec:real-part z1) z2)))
+ (if (recnum? z2)
+ (and (real:exact0= (rec:imag-part z2))
+ (real:eqv? z1 (rec:imag-part z2)))
+ ((copy real:eqv?) z1 z2))))
+\f
(define (complex:= z1 z2)
(if (recnum? z1)
(if (recnum? z2)
(if (object-type? (object-type x) y)
(and (not (fix:fixnum? x))
(if (number? y)
- (and (= x y)
- (boolean=? (exact? x) (exact? y)))
+ (number:eqv? x y)
(and (object-type? (ucode-type vector) y)
(fix:zero? (vector-length x))
(fix:zero? (vector-length y)))))
(and (number? x)
(number? y)
- (= x y)
- (boolean=? (exact? x) (exact? y))))))
+ (number:eqv? x y)))))
(define (equal? x y)
(or (eq? x y)
((string? y)
(string=? x y))
((number? y)
- (and (= x y)
- (boolean=? (exact? x) (exact? y))))
+ (number:eqv? x y))
((cell? y)
(equal? (cell-contents x) (cell-contents y)))
((bit-string? y)
(else #f))
(and (number? x)
(number? y)
- (= x y)
- (boolean=? (exact? x) (exact? y))))))
\ No newline at end of file
+ (number:eqv? x y)))))
\ No newline at end of file
((flo:= x y) y)
(else (error:bad-range-argument (if (flo:finite? x) x y) 'FLO:MAX))))
+;;; XXX FLO:FINITE?, FLO:NAN?, FLO:EQV?, &c., are cute, but should be
+;;; replaced by primitives.
+
(define (flo:finite? x)
(if (or (flo:> x 1.) (flo:< x -1.))
(not (flo:= x (flo:/ x 2.)))
(and (flo:<= x 1.) (flo:>= x -1.))))
+(define (flo:eqv? x y)
+ ;; (bit-string=? (flo:->bit-string x) (flo:->bit-string y))
+ (if (flo:= x y)
+ (or (not (flo:zero? x))
+ ;; XXX Kludgey but expedient test for zero sign.
+ (flo:= (flo:atan2 x -1.) (flo:atan2 y -1.)))
+ ;; XXX (and (flo:nan? x) (flo:nan? y) ...)
+ #f))
+
(define-integrable (int:->flonum n)
((ucode-primitive integer->flonum 2) n #b10))
flo:ceiling
flo:ceiling->exact
flo:cos
+ flo:eqv?
flo:exp
flo:expm1
flo:expt
(make-polar complex:make-polar)
(make-rectangular complex:make-rectangular)
(negative? complex:negative?)
+ (number:eqv? complex:eqv?)
(number? complex:complex?)
(numerator complex:numerator)
(numerator->exact complex:numerator->exact)