Re: precision on op:numeric-divide

Jim Melton wrote:

> retain the numerator 
> and denominator themselves, thus effectively holding "1/3" exactly.  I 
> know of a couple of (very old, research) languages that do this, but 
> they are rather complicated and cumbersome.

Common Lisp et al does that, though it simplifies fractions:
6/4 -> 3/2.  There is certainly more prior art for this than
for repeating decimals, but I think repeating decimals would
be more usefully integrated into "enterprise" applications.

Common Lisp may be old and unfashionable, but it
is an industrial-strength production language.  And while parts
of it may be complicated, its numerics aren't particularly
complicated.  Many Scheme implementations (including mine)
also support exact rationals, and Scheme is really a small
language.

If your language supports infinite-precision integers then
supporting exact rationals seems a reasonable extension.

Damien@sodatech.com wrote:

 > My example wasn't the best.  What I am trying to say is that repeatedly
 > performing a division a / b (with b > a) can very quickly lead to
 > unbounded growth in the height of the answer, whereas this is not the
 > case with floating point or integer division.
 >
 > Controlling this can be difficult.  It does not mean exact rationals
 > have no uses, just that they are not as useful as many people expect.

Agreed.  That is why *also* want to support floating point numbers,
as Common Lisp and Scheme do.  (Scheme doesn't specify floating
point numbers, but calls them "inexact real" numbers.)  And as
XQuery/Schema also does.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/

Received on Wednesday, 10 December 2003 12:08:54 UTC