(else (slow-method n d))))
(define (int:->inexact n)
- (cond ((fixnum? n) (fixnum->flonum n))
- ((integer->flonum n #b00))
- (else (if (int:negative? n) (flo:-inf.0) (flo:+inf.0)))))
+ (cond ((fixnum? n)
+ ;; The primitive (via hardware) will raise inexact if necessary.
+ (fixnum->flonum n))
+ ((integer->flonum n #b00)
+ => (lambda (x)
+ ;; The primitive does not always raise inexact for us,
+ ;; though it does raise overflow.
+ (if (not (and (flo:finite? x) (int:= (flo:->integer x) n)))
+ (flo:raise-exceptions! (flo:exception:inexact-result)))
+ x))
+ (else
+ (flo:raise-exceptions!
+ (fix:or (flo:exception:overflow) (flo:exception:inexact-result)))
+ (if (int:negative? n) (flo:-inf.0) (flo:+inf.0)))))
\f
(define (flo:significand-digits radix)
(cond ((int:= radix 10)
(,(- (+ 3 (expt flo:radix flo:precision)))
,(- (+ 4 (expt flo:radix. flo:precision))))
(,(expt flo:radix (+ 1 flo:normal-exponent-max))
- +inf.0
- ;; Missing overflow exception.
- ,expect-failure)
+ +inf.0)
(,(expt flo:radix (* 2 flo:normal-exponent-max))
- +inf.0
- ;; Missing overflow exception.
- ,expect-failure)
+ +inf.0)
(,(- (expt flo:radix (+ 1 flo:normal-exponent-max)))
-inf.0)
(,(- (expt flo:radix (* 2 flo:normal-exponent-max)))
- -inf.0
- ;; Missing overflow exception.
- ,expect-failure)
+ -inf.0)
(,(- (expt flo:radix (+ 1 flo:normal-exponent-max))
(expt flo:radix (- (+ 1 flo:normal-exponent-max) flo:precision)))
,flo:largest-positive-normal)
(,(- (* (expt flo:radix (+ 1 flo:normal-exponent-max))
(- 1 (expt flo:radix (- flo:precision))))
1)
- ,flo:largest-positive-normal
- ;; Missing inexact-result exception.
- ,expect-failure)
+ ,flo:largest-positive-normal)
(,(- (* (expt flo:radix (+ 1 flo:normal-exponent-max))
(- 1 (expt flo:radix (- flo:precision)))))
-inf.0
(,(- (- (* (expt flo:radix (+ 1 flo:normal-exponent-max))
(- 1 (expt flo:radix (- flo:precision))))
1))
- ,(- flo:largest-positive-normal)
- ;; Missing inexact-result exception.
- ,expect-failure))
+ ,(- flo:largest-positive-normal)))
(lambda (x y #!optional xfail)
(assert-exact x)
(assert-inexact y)