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

Re: XPath 1.0: sum() and precision

Subject: Re: XPath 1.0: sum() and precision
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Fri, 28 Sep 2012 00:16:14 +0100
Re:  XPath 1.0: sum() and precision
On 27/09/2012 23:09, Florent Georges wrote:
Andrew Welch wrote:

Hi,

I guess if you are stuck with xpath 1.0 it would have to be
substring... (or split on the ., then round() on the first 3 digits
eg the 490)
   Thanks Andrew.  That's what I thought too, but I wanted to avoid
string functions for that purpose.  What I've done in the meantime is
replacing sum(...) by:

round(sum(...) * 100) div 100

that is, "moving the dot right", rounding as an integer, then "moving
the dot left" again.



But can't the "div 100" itself have a rounding error that means you don't get an exact answer?


In pure XPath 1.0, without format-number(), I suspect string manipulation is the only reliable way.

Michael Kay
Saxonica

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.