Well, rational only takes one argument, but the reasoning is sound. What the OP wants to use is “rationalize” which will pick the closest rational to the FP representation.
* (rationalize 7.2)
* 36/5
From: <
owner-lisp-hug@lispworks.com> on behalf of Christopher Riesbeck <
c-riesbeck@northwestern.edu>
Reply-To: Christopher Riesbeck <
c-riesbeck@northwestern.edu>
Date: Monday, April 6, 2020 at 3:49 PM
To: Ramamoorthi Bhaskar <
bhaskar51@gmail.com>
Cc: "
lisp-hug@lispworks.com" <
lisp-hug@lispworks.com>
Subject: EXT: Re: The rational function
(rational 72 100) does what I’m guessing you expected.
7..2 is a different number with a much longer binary fraction
On Apr 6, 2020, at 2:36 PM, Ramamoorthi Bhaskar <
bhaskar51@gmail.com<
mailto:bhaskar51@gmail.com>> wrote:
I can't figure out why (rational 7.2) or (rational 7.20) should produce
7549747/1048576
Any ideas?
Thanks
Bhaskar
------------------
Christopher Riesbeck (he/him/his)
Associate Professor, Computer Science,
McCormick School of Engineering, Northwestern
Director, MS in Computer Science
Co-director, The Center for Computer Science and Learning Sciences
Home page:
https://users.cs.northwestern.edu/~riesbeckCalendar:
https://users.cs.northwestern.edu/~riesbeck/calendar-weekly.html