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

xslt and xpath rounding

From: Peter Rushforth <prushforth@rogers.com>
Date: Wed, 20 Dec 2006 13:36:04 -0500
Message-ID: <00bb01c72465$b6867370$be49684a@peterqta28n9cv>
To: "Michael Kay" <mhk@mhk.me.uk>, <xsl-editors@w3.org>, <public-qt-comments@w3.org>
Dear Dr. Kay and xsl-editors:

Yes, I suppose the comments regarding math functionality
should be sent to the xpath editors - I hadn't thought
of that and I will do just that.  Thank you.

With respect to the rounding issue, I believe it applies 
equally to xpath and xslt specifications, since the xslt format-number
function performs half-to-even rounding but offers no other
options.  The xpath specification provides the round function
which rounds up to the nearest integer, and the new 
round-half-to-even function.  I believe that the
IEEE 754 standard provides four rounding methods
other than the unbiased half-to-even method, including 
round towards zero, round towards positive infinity and round towards
negative infinity.

I have noticed that the default rounding method of half-to-even
in XSLT is at odds with default rounding in commonly available programs
such as MS-Excel, Oracle, SAS and probably many other
applications, as well as what I was taught in high school math!
If calculations are to be done in XSLT, it should
be possible to create equivalent results as those calculation
environments, which it currently is not due to the lack of a half-up
rounding method.

It is not a viable solution to convert the result of a calculation for
rounding in external environments, such as java:  the conversion
changes the precision of the result such that *especially* calculation of
numbers which are exactly half way between two numbers are subject
to precision changes during conversion, and rounded results
are unpredictable and therefore in error.

Peter
  ----- Original Message ----- 
  From: Michael Kay 
  To: 'Peter Rushforth' ; xsl-editors@w3.org 
  Sent: Wednesday, December 20, 2006 8:50 AM
  Subject: RE: xslt and math


  I assume this is intended as a comment on the XPath 2.0 specification, however the correct address for comments on that spec is public-qt-comments@w3.org
Received on Wednesday, 20 December 2006 18:41:14 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 5 February 2014 07:13:58 UTC