Next: , Previous: math primes, Up: Top


17 (math rationalize)

17.1 Overview

 
 Functions for rationalizing numbers, and finding simple ratios.

17.2 Usage

— Function: rationalize x e

Returns an exact number that is within e of x. 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.

— Function: find-ratio x e

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)