[XSL-LIST Mailing List Archive Home]
[xsl] XPath / XSLT 2.1 - Rounding algorithms
Subject: [xsl] XPath / XSLT 2.1 - Rounding algorithms|
From: "Rushforth, Peter" <prushfor@xxxxxxxxxxx>
Date: Thu, 13 Nov 2008 16:57:17 -0500
A couple of years ago, I ran into a need to call extension functions
to round numbers in the "traditional" way: to round half up for results of
.5 (or more). I found that it was only possible with XSLT to round to the
I am aware that rounding to the nearest even number is the theoretically
thing to do, this was pointed out at the time.
However, this is not the default rounding method in most commonly available
office software, and lots of other types of software.
Being able to reproduce results from existing systems might help in the
growth of XPath and XSLT in replacing non-standard languages in the
workplace. In any case, for some applications, it could be important to have
access to the IEEE standard algorithms without having to resort to
(complicated) extension functions / jump through hoops.
Specifically, round-half-up(decimal_num,num_digits), where 'up' means towards
positive or negative infinity, is what I'm looking for.
Technology Advisor / Conseiller technique
GeoConnections / GioConnexions
650-615 Booth St. / rue Booth
Ottawa ON K1A 0E9
E-mail / Courriel: Peter.Rushforth @ NRCan.gc.ca
Phone / Tilephone: (613) 943-0784
Fax / telecopier: (613) 947-2410