Next: Promises, Previous: Multi-argument Apply, Up: Standards Support [Contents][Index]
Computes the correct result for exact arguments (provided the implementation supports exact rational numbers of unlimited precision); and produces a reasonable answer for inexact arguments when inexact arithmetic is implemented using floating-point.
Rationalize
has limited use in implementations lacking exact
(non-integer) rational numbers. The following procedures return a list
of the numerator and denominator.
find-ratio
returns the list of the simplest
numerator and denominator whose quotient differs from x by no more
than e.
(find-ratio 3/97 .0001) ⇒ (3 97) (find-ratio 3/97 .001) ⇒ (1 32)
find-ratio-between
returns the list of the simplest
numerator and denominator between x and y.
(find-ratio-between 2/7 3/5) ⇒ (1 2) (find-ratio-between -3/5 -2/7) ⇒ (-1 2)