[XSLT 2.0] Question about decimal arithmetic

Divison of decimal numbers is not well specified.  There are two aspects of the problem:

   1. How many fraction digits should be kept? For example, what is the result of 1.0 div 3.0?

   2. Should the answer be rounded or truncated?

I have been told previously that the answer is "implementation defined", but it's hard for me to accept arithmetic that is "implementation defined".  Since I am chairman of the OASIS XSLT Conformance committee, I would like to be able to produce a test suite that expects known answers to numerical operations.

I have a suggestion:

For XSLT processors which are schema-aware, it is possible to specify the number of fraction digits in the result from any operation.  In this case, my first question has a clear answer.  I propose that some mechanism be added to XSLT so that, even without schemas, the number of fraction digits can be specified.  I believe that this would solve my problem, and that, along with a statement in the spec about rounding, it would make decimal arithmetic precise, as it should be.

jeff kenton

Received on Thursday, 20 November 2003 15:04:37 UTC