Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

integer?, rational?, decimal dot and the #i prefix

2 views
Skip to first unread message

Marco Maggi

unread,
Oct 15, 2009, 3:41:24 PM10/15/09
to
Ciao,

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

leppie

unread,
Oct 16, 2009, 2:17:17 AM10/16/09
to
Hi Marco

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

leppie

unread,
Oct 16, 2009, 2:19:19 AM10/16/09
to
On Oct 15, 9:41 pm, Marco Maggi <mrc....@gmail.com> wrote:

>   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 :)

0 new messages