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

[XSLT 2.0] Question about decimal arithmetic

From: Jeff Kenton <jkenton@datapower.com>
Date: Thu, 20 Nov 2003 15:04:22 -0500
Message-ID: <3FBD1E46.3030508@datapower.com>
To: public-qt-comments@w3.org

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

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