W3C home > Mailing lists > Public > public-qt-comments@w3.org > December 2003

Re: precision on op:numeric-divide

From: Per Bothner <per@bothner.com>
Date: Wed, 10 Dec 2003 09:04:39 -0800
Message-ID: <3FD75227.5020705@bothner.com>
To: Jim Melton <jim.melton@acm.org>
Cc: Damien Fisher <damien@sodatech.com>, www-ql@w3.org, public-qt-comments@w3.org

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:55 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:45:15 UTC