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 toinexact.
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.:inexact. At least then, if (fldiv x y) is a representable flonum integer, it will be computed correctly.
(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
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 399 |
Nodes: | 16 (2 / 14) |
Uptime: | 39:39:45 |
Calls: | 8,336 |
Calls today: | 13 |
Files: | 13,155 |
Messages: | 5,891,234 |
Posted today: | 1 |