- (let (;; I think this works because of an invariant of the
- ;; two components of a COMPLEX are always coerced to
- ;; be the same, e.g. (COMPLEX 1.0 3/2) => #C(1.0 1.5).
- ;; Dunno why that holds, though -- ANSI? Python
- ;; tradition? marsh faerie spirits? -- WHN 2001-10-27
- (num (if (complexp object)
- (realpart object)
- object)))
- (ecase (numeric-type-class type)
- (integer (integerp num))
- (rational (rationalp num))
- (float
- (ecase (numeric-type-format type)
- (short-float (typep num 'short-float))
- (single-float (typep num 'single-float))
- (double-float (typep num 'double-float))
- (long-float (typep num 'long-float))
- ((nil) (floatp num))))
- ((nil) t)))
- #!-negative-zero-is-not-zero
- (flet ((bound-test (val)
- (let ((low (numeric-type-low type))
- (high (numeric-type-high type)))
- (and (cond ((null low) t)
- ((listp low) (> val (car low)))
- (t (>= val low)))
- (cond ((null high) t)
- ((listp high) (< val (car high)))
- (t (<= val high)))))))
- (ecase (numeric-type-complexp type)
- ((nil) t)
- (:complex
- (and (complexp object)
- (bound-test (realpart object))
- (bound-test (imagpart object))))
- (:real
- (and (not (complexp object))
- (bound-test object)))))
- #!+negative-zero-is-not-zero
- (labels ((signed-> (x y)
- (if (and (zerop x) (zerop y) (floatp x) (floatp y))
- (> (float-sign x) (float-sign y))
- (> x y)))
- (signed->= (x y)
- (if (and (zerop x) (zerop y) (floatp x) (floatp y))
- (>= (float-sign x) (float-sign y))
- (>= x y)))
- (bound-test (val)
- (let ((low (numeric-type-low type))
- (high (numeric-type-high type)))
- (and (cond ((null low) t)
- ((listp low)
- (signed-> val (car low)))
- (t
- (signed->= val low)))
- (cond ((null high) t)
- ((listp high)
- (signed-> (car high) val))
- (t
- (signed->= high val)))))))
- (ecase (numeric-type-complexp type)
- ((nil) t)
- (:complex
- (and (complexp object)
- (bound-test (realpart object))
- (bound-test (imagpart object))))
- (:real
- (and (not (complexp object))
- (bound-test object)))))))
+ (let (;; I think this works because of an invariant of the
+ ;; two components of a COMPLEX are always coerced to
+ ;; be the same, e.g. (COMPLEX 1.0 3/2) => #C(1.0 1.5).
+ ;; Dunno why that holds, though -- ANSI? Python
+ ;; tradition? marsh faerie spirits? -- WHN 2001-10-27
+ (num (if (complexp object)
+ (realpart object)
+ object)))
+ (ecase (numeric-type-class type)
+ (integer (integerp num))
+ (rational (rationalp num))
+ (float
+ (ecase (numeric-type-format type)
+ (short-float (typep num 'short-float))
+ (single-float (typep num 'single-float))
+ (double-float (typep num 'double-float))
+ (long-float (typep num 'long-float))
+ ((nil) (floatp num))))
+ ((nil) t)))
+ (flet ((bound-test (val)
+ (let ((low (numeric-type-low type))
+ (high (numeric-type-high type)))
+ (and (cond ((null low) t)
+ ((listp low) (> val (car low)))
+ (t (>= val low)))
+ (cond ((null high) t)
+ ((listp high) (< val (car high)))
+ (t (<= val high)))))))
+ (ecase (numeric-type-complexp type)
+ ((nil) t)
+ (:complex
+ (and (complexp object)
+ (bound-test (realpart object))
+ (bound-test (imagpart object))))
+ (:real
+ (and (not (complexp object))
+ (bound-test object)))))))