summaryrefslogtreecommitdiffstats
path: root/ratize.txi
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:29 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:29 -0800
commit8466d8cfa486fb30d1755c4261b781135083787b (patch)
treec8c12c67246f543c3cc4f64d1c07e003cb1d45ae /ratize.txi
parent87b82b5822ca54228cfa6df29be3ad9d4bc47d16 (diff)
downloadslib-8466d8cfa486fb30d1755c4261b781135083787b.tar.gz
slib-8466d8cfa486fb30d1755c4261b781135083787b.zip
Import Upstream version 3a1upstream/3a1
Diffstat (limited to 'ratize.txi')
-rw-r--r--ratize.txi41
1 files changed, 41 insertions, 0 deletions
diff --git a/ratize.txi b/ratize.txi
new file mode 100644
index 0000000..63b5917
--- /dev/null
+++ b/ratize.txi
@@ -0,0 +1,41 @@
+@code{(require 'rationalize)}
+@ftindex rationalize
+
+
+@defun rationalize x e
+
+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.
+
+@end defun
+@code{Rationalize} has limited use in implementations lacking exact
+(non-integer) rational numbers. The following procedures return a list
+of the numerator and denominator.
+
+
+@defun find-ratio x e
+
+@code{find-ratio} returns the list of the @emph{simplest}
+numerator and denominator whose quotient differs from @var{x} by no more
+than @var{e}.
+
+@format
+@t{(find-ratio 3/97 .0001) @result{} (3 97)
+(find-ratio 3/97 .001) @result{} (1 32)
+}
+@end format
+@end defun
+
+@defun find-ratio-between x y
+
+@code{find-ratio-between} returns the list of the @emph{simplest}
+numerator and denominator between @var{x} and @var{y}.
+
+@format
+@t{(find-ratio-between 2/7 3/5) @result{} (1 2)
+(find-ratio-between -3/5 -2/7) @result{} (-1 2)
+}
+@end format
+@end defun