XPath 2.0 -- Question about decimal arithmetic

I have looked at the XPath 2.0 WD, the XML Schema Recommendation (Part 2: 
Datatypes), and the XQuery 1.0 and XPath 2.0 Functions and Operators WD.

I have questions about decimal arithmetic:

It is clear what the intent is if you have an infinite precision 
representation of decimals.  However, if you limit yourself to a real 
implementation (18 decimal digits conforms to the Schema Recommendation), you 
run into questions when you start doing arithmetic.  For example:

Addition:  a + b -- if a has 15 digits before the decimal point and b has 15 
digits after the decimal, which 18 digits do you keep? Do you round the 
result? Subtraction and multipl;ication have similar questions.

Division:  this is the biggest problem.  If you divide 1.0 div 3.0, is the 
answer 0.3 or 0.333333333333333333? If the latter, this will propagate through 
any following operations, including output.

Since all numbers in existing (pre 2.0) stylesheets that would have been 
doubles will now default to decimal (was this intended?), this is a serious 
question.

Thanks.

-- 
--------------------------
Jeff Kenton
DataPower Technology, Inc.

Received on Monday, 7 October 2002 12:48:52 UTC