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: | 296 |
Nodes: | 16 (2 / 14) |
Uptime: | 79:12:24 |
Calls: | 6,658 |
Calls today: | 4 |
Files: | 12,203 |
Messages: | 5,333,083 |
Posted today: | 1 |