- ;; an integer to some power
- (case (numeric-type-class y-type)
- (integer
- ;; Positive integer to an integer power is either an
- ;; integer or a rational.
- (let ((lo (or (interval-low bnd) '*))
- (hi (or (interval-high bnd) '*)))
- (if (and (interval-low y-int)
- (>= (type-bound-number (interval-low y-int)) 0))
- (specifier-type `(integer ,lo ,hi))
- (specifier-type `(rational ,lo ,hi)))))
- (rational
- ;; Positive integer to rational power is either a rational
- ;; or a single-float.
- (let* ((lo (interval-low bnd))
- (hi (interval-high bnd))
- (int-lo (if lo
- (floor (type-bound-number lo))
- '*))
- (int-hi (if hi
- (ceiling (type-bound-number hi))
- '*))
- (f-lo (if lo
- (bound-func #'float lo)
- '*))
- (f-hi (if hi
- (bound-func #'float hi)
- '*)))
- (specifier-type `(or (rational ,int-lo ,int-hi)
- (single-float ,f-lo, f-hi)))))
- (float
- ;; A positive integer to a float power is a float.
- (modified-numeric-type y-type
- :low (interval-low bnd)
- :high (interval-high bnd)))
- (t
- ;; A positive integer to a number is a number (for now).
- (specifier-type 'number))))
- ((csubtypep x-type (specifier-type 'rational))
- ;; a rational to some power
- (case (numeric-type-class y-type)
- (integer
- ;; A positive rational to an integer power is always a rational.
- (specifier-type `(rational ,(or (interval-low bnd) '*)
- ,(or (interval-high bnd) '*))))
- (rational
- ;; A positive rational to rational power is either a rational
- ;; or a single-float.
- (let* ((lo (interval-low bnd))
- (hi (interval-high bnd))
- (int-lo (if lo
- (floor (type-bound-number lo))
- '*))
- (int-hi (if hi
- (ceiling (type-bound-number hi))
- '*))
- (f-lo (if lo
- (bound-func #'float lo)
- '*))
- (f-hi (if hi
- (bound-func #'float hi)
- '*)))
- (specifier-type `(or (rational ,int-lo ,int-hi)
- (single-float ,f-lo, f-hi)))))
- (float
- ;; A positive rational to a float power is a float.
- (modified-numeric-type y-type
- :low (interval-low bnd)
- :high (interval-high bnd)))
- (t
- ;; A positive rational to a number is a number (for now).
- (specifier-type 'number))))
- ((csubtypep x-type (specifier-type 'float))
- ;; a float to some power
- (case (numeric-type-class y-type)
- ((or integer rational)
- ;; A positive float to an integer or rational power is
- ;; always a float.
- (make-numeric-type
- :class 'float
- :format (numeric-type-format x-type)
- :low (interval-low bnd)
- :high (interval-high bnd)))
- (float
- ;; A positive float to a float power is a float of the
- ;; higher type.
- (make-numeric-type
- :class 'float
- :format (float-format-max (numeric-type-format x-type)
- (numeric-type-format y-type))
- :low (interval-low bnd)
- :high (interval-high bnd)))
- (t
- ;; A positive float to a number is a number (for now)
- (specifier-type 'number))))
- (t
- ;; A number to some power is a number.
- (specifier-type 'number))))
+ ;; an integer to some power
+ (case (numeric-type-class y-type)
+ (integer
+ ;; Positive integer to an integer power is either an
+ ;; integer or a rational.
+ (let ((lo (or (interval-low bnd) '*))
+ (hi (or (interval-high bnd) '*)))
+ (if (and (interval-low y-int)
+ (>= (type-bound-number (interval-low y-int)) 0))
+ (specifier-type `(integer ,lo ,hi))
+ (specifier-type `(rational ,lo ,hi)))))
+ (rational
+ ;; Positive integer to rational power is either a rational
+ ;; or a single-float.
+ (let* ((lo (interval-low bnd))
+ (hi (interval-high bnd))
+ (int-lo (if lo
+ (floor (type-bound-number lo))
+ '*))
+ (int-hi (if hi
+ (ceiling (type-bound-number hi))
+ '*))
+ (f-lo (if lo
+ (bound-func #'float lo)
+ '*))
+ (f-hi (if hi
+ (bound-func #'float hi)
+ '*)))
+ (specifier-type `(or (rational ,int-lo ,int-hi)
+ (single-float ,f-lo, f-hi)))))
+ (float
+ ;; A positive integer to a float power is a float.
+ (modified-numeric-type y-type
+ :low (interval-low bnd)
+ :high (interval-high bnd)))
+ (t
+ ;; A positive integer to a number is a number (for now).
+ (specifier-type 'number))))
+ ((csubtypep x-type (specifier-type 'rational))
+ ;; a rational to some power
+ (case (numeric-type-class y-type)
+ (integer
+ ;; A positive rational to an integer power is always a rational.
+ (specifier-type `(rational ,(or (interval-low bnd) '*)
+ ,(or (interval-high bnd) '*))))
+ (rational
+ ;; A positive rational to rational power is either a rational
+ ;; or a single-float.
+ (let* ((lo (interval-low bnd))
+ (hi (interval-high bnd))
+ (int-lo (if lo
+ (floor (type-bound-number lo))
+ '*))
+ (int-hi (if hi
+ (ceiling (type-bound-number hi))
+ '*))
+ (f-lo (if lo
+ (bound-func #'float lo)
+ '*))
+ (f-hi (if hi
+ (bound-func #'float hi)
+ '*)))
+ (specifier-type `(or (rational ,int-lo ,int-hi)
+ (single-float ,f-lo, f-hi)))))
+ (float
+ ;; A positive rational to a float power is a float.
+ (modified-numeric-type y-type
+ :low (interval-low bnd)
+ :high (interval-high bnd)))
+ (t
+ ;; A positive rational to a number is a number (for now).
+ (specifier-type 'number))))
+ ((csubtypep x-type (specifier-type 'float))
+ ;; a float to some power
+ (case (numeric-type-class y-type)
+ ((or integer rational)
+ ;; A positive float to an integer or rational power is
+ ;; always a float.
+ (make-numeric-type
+ :class 'float
+ :format (numeric-type-format x-type)
+ :low (interval-low bnd)
+ :high (interval-high bnd)))
+ (float
+ ;; A positive float to a float power is a float of the
+ ;; higher type.
+ (make-numeric-type
+ :class 'float
+ :format (float-format-max (numeric-type-format x-type)
+ (numeric-type-format y-type))
+ :low (interval-low bnd)
+ :high (interval-high bnd)))
+ (t
+ ;; A positive float to a number is a number (for now)
+ (specifier-type 'number))))
+ (t
+ ;; A number to some power is a number.
+ (specifier-type 'number))))