On Thu, 12 Jul 2001 18:09:07 -0400, Dan Sugalski wrote:
>Precision is a useful thing with bigfloats so something like 1/3 doesn't
>chew up all your available memory.
1/3 would better be represented as a ratio, 1 over 3.
We've been here before, haven't we?
Ratio's, or whatever you'd want to call them, with both nominator and
denominator integers, would be a very useful internal representation for
many numerical applications. $1.23 can be represented as 123 over 100,
or EXACTLY 123 cents. You can't have that with floats. Multiplication
and division can happen without loss of precision. A Greatest Common
Divisor algorithm like Euclid's, can prevent nominators and denominators
from getting out of control. See for example this page,
<http://www.mike95.com/c_plusplus/tutorial/algorithms/Euclid.asp>, for
how. (Changing the program from using recursion to using a loop is
trivial.)
--
Bart.