On Sunday, May 10, 2020 at 1:29:22 AM UTC+9, Brad Lucier wrote:
If a system has (roughly) 64-bit fixnums, then in the following example all exact integers are fixnums, all flonums are convertible to fixnums, etc.:
(define x (flexpt 2. 56.))
(define y (+ (flexpt 2. 28.) 1.))
(display (= y (exact y))) (newline)
(display (= x (exact x))) (newline)
(display (modulo (exact x) (exact y))) (newline)
(display (flmod x y)) (newline)
Frederic Hamel showed me the reduced argument size.
To be honest, I don't see how to compute flmod and fldiv correctly using IEEE 754 arithmetic (especially because they can take non-integer arguments) except by converting arguments to exact, computing the exact equivalents, then converting back to
inexact. At least then, if (fldiv x y) is a representable flonum integer, it will be computed correctly.
Chibi gets this right on Linux using a trivial wrapper around remquo(3).
--
Alex
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)