Alternate API Bradley Lucier 31 Oct 2020 19:49 UTC

I've been thinking about the various comments and suggestions, and I'd
like to propose the following API, which seems simple and at the same
time general enough to cover many (but not all) situations.

It's not particular to NaNs, but I think it will solve the NaN

(decompose-flonum flonum)
=> (values sign exponent mantissa flonum-format)

(compose-flonum sign exponent mantissa flonum-format)
=> flonum

(define-struct flonum-format
   exponent-bits exponent-bias
   mantissa-bits
   gradual-underflow?)

(flonum-eqv? flonum1 flonum2)
=> #t iff flonum1 and flonum2 have the same flonum-format and
the same sign, exponent, and mantissa

(flonum-nan-signaling? flonum)
=> #t if flonum is a NaN and signaling, #f if flonum is a Nan and
nonsignaling, and to be determined in other cases.

If there are several formats with the same parameters then one can
define flonum-format constants with the same parameters and different names.

I don't see how to make this work with IBM's double-double format, but
it's a start.

Brad