Note Observations on rational? and exact? 

Forum: Com Sci 12500, U Chicago, Autumn 2002, Discuss Classwork
Re: News Project Step #1, due Friday 8 November
Date: 2002, Nov 07
From: Mark Kittisopikul <markkitt@uchicago.edu>

After some discussions with Andrew Cone and some research I have determined some behavior about rational? and exact? that was not so obvious to me at first. So here we go:

Source of confusion
(rational? 2.5)
;Value: #t

(exact? 2.5)
;Value: ()

(rational? (/ 5 2))
;Value: #t

(exact? (/ 5 2))
;Value: #t

My discussions with Andrew involved if 2.5 was a valid rational number for our implementation of ratintvl?. I assumed that it was and he had originally assumed they were not. I believe the correct interpretation is that 2.5 is a valid rational number for our use (as well as 53.34391039, to rub in the point). If I'm wrong here, correct me. Anyways, the weird behavior of Scheme saying that 2.5 was rational but not exact intrigued me.

Numbers in Scheme seem to have a context as well that determines whether they are exact or inexact as the MIT Scheme Manual Says.

I could see how this may have an affect on us later in the project.


Messages

1. Warning We'd better use exact rationals by Mike O'Donnell, 2002, Nov 07
1. Question Endpoints only? by Mark Kittisopikul, 2002, Nov 07
1. Feedback Let's stick to exact rationals in all cases by Mike O'Donnell, 2002, Nov 07
2. More Robby Findler confirms that all Scheme reals are rationals by Mike O'Donnell, 2002, Nov 11
2. Note inexact->exact by Mark Kittisopikul, 2002, Nov 07
1. Warning Don't use inexact->exact: it just pretends that something is exact by Mike O'Donnell, 2002, Nov 07

to: "Observations on rational? and exact?"