RE: Rationals

Hello,

A rational number is essentially a pair of integers. Thus, we can determine the set of core rational literals by simply restricting
the sizes of these two integers. For example, we might restrict both to 32 bits, which would give us on most platforms additional 32
bits (of long numbers) to perform various calculations. I don't think we should talk about the supported number of decimals for
rationals -- this kind of defeats the whole purpose of having rationals in the first place. Note also that rationals are not
tantamount to arbitrary precision arithmetic: the precision is defined by the bounds on the integers that you use to implement the
rational.

If you implement rationals as a pair of integers, then all manipulations of rationals become rather easy. Comparing rationals and
decimals and/or floats can be performed by promoting the decimal/float to a rational and then comparing the rational numbers as
usual. The only thing I'm not yet sure of is how to deal with the cases of very large numbers. Namely, floats can be converted to
rationals, but the numerator and/or denominator can be pretty big. It is not immediately clear to me how to implement comparison of
such numbers with rationals without requiring some kind of BigInteger support.

Regards,

	Boris

> -----Original Message-----
> From: public-owl-wg-request@w3.org [mailto:public-owl-wg-request@w3.org] On Behalf Of Bijan Parsia
> Sent: 10 November 2008 21:34
> To: Alan Ruttenberg
> Cc: W3C OWL Working Group
> Subject: Re: Rationals
> 
> 
> On 10 Nov 2008, at 21:02, Alan Ruttenberg wrote:
> [snip]
> > Note: Implementations of rational numbers I'm aware of use arbitrary
> > precision arithmetic.
> 
> To get arbitrary precision rationals.
> 
> > As I recall, the reason we did not require
> > arbitrary precision integer arithmetic for minimal conformance so as
> > to avoid the necessity of all implementation using such.
> 
> Rationals and decimals are closely related. Just as we specced a
> lower bound of decimal support, we can spec a lower bound on rational
> support.
> <http://www.w3.org/2007/OWL/wiki/Syntax#Numbers>
> """The literals of xsd:decimal and the datatypes derived from
> xsd:integer are mapped to arbitrarily large and arbitrarily precise
> numbers. An OWL 2 implementation may support all such literals;
> however, it must support at least the following literals, called core
> literals, which can be easily mapped to the primitive datatypes
> commonly found in modern implementation platforms:
> 
> All xsd:float and xsd:double literals are core literals.
> A literal of type xsd:integer or of a type derived from xsd:integer
> is a core literal if its data value is in the value space of xsd:long.
> A literal of type xsd:decimal is a core literal if its data value is
> a number with absolute value less than 1016 and the representation of
> the number requires at most 16 digits in total."""
> 
> In fact, we could easily adapt the lower bounds on decimals to
> rationals.
> 
> Cheers,
> Bijan.
> 

Received on Tuesday, 11 November 2008 10:51:23 UTC