[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Implementation of read-ieee-float64

In the implementation of the withdrawn SRFI-56, read-ieee-float64 has the following code

    (define (mantissa expn b2 b3 b4 b5 b6 b7 b8)
      (case expn   ; recognize special literal exponents
        ((255) #f) ; won't handle NaN and +/- Inf
        ((0)       ; denormalized
         (exact->inexact (* (expt 2.0 (- 1 (+ 1023 52)))
                            (combine b2 b3 b4 b5 b6 b7 b8))))
          (* (expt 2.0 (- expn (+ 1023 52)))
             (combine (+ b2 16) b3 b4 b5 b6 b7 b8))))))

Gambit 4.0b15 fails some srfi-56 tests because the first instance of 2.0 is not 2; unfortunately, Gambit-C calculates

(expt 2.0 -1074)


(/ (expt 2.0 1074))

Since the exponent range of IEEE arithmetic is not symmetric, (expt 2.0 1074) is +inf.0, yet (expt 2.0 -1074) is not 0.

If both instances of 2.0 are changed to 2, then Gambit passes all the tests. I think that this is what you may have meant in the first place, because you take the trouble to call exact->inexact on what is already an inexact number.