[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XPath / XSLT 2.1 - Rounding algorithms

Subject: XPath / XSLT 2.1 - Rounding algorithms
From: "Rushforth, Peter" <prushfor@xxxxxxxxxxx>
Date: Thu, 13 Nov 2008 16:57:17 -0500
 XPath / XSLT 2.1 - Rounding algorithms
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.

Peter Rushforth
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

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.