R6RS states that:
If x is a real number object, then (rational? x) is
true if and only if there exist exact integer objects k1
and k2 such that (= x (/ k1 k2)) and (= (numerator x)
k1) and (= (denominator x) k2) are all true.
the comparison function "=" does not care about exactness:
(= 3 3.0) => #t
(= 3 #i3.0) => #t
so the inexact numbers 3.0 and #i3.0 are considered
rationals by "rational?". I understand that flonums are, in
truth, rational because of limited precision in the
representation, but why are they considered rationals along
with exact rationals?
R6RS states that:
implementations must support exact integer objects and
exact rational number objects of practically unlimited
size and precision
so flonums are not rationals to allow an implementation to
avoid support for exact rationals.
With the given definition, the only real numbers
(according to "real?") that are not also rationals
(according to "rational?") are infinities and NaNs.
Correct?
--
Marco Maggi
I had the same issue, and asked on the R6RS list [1].
Will Clinger provides an informative answer.
Cheers
leppie
[1] http://lists.r6rs.org/pipermail/r6rs-discuss/2009-February/004359.html
> With the given definition, the only real numbers
> (according to "real?") that are not also rationals
> (according to "rational?") are infinities and NaNs.
> Correct?
Yes, that is correct :)