Re: sum() function giving strange result
> I am worried about the output 151.64999999999998. Why is it outputting this > value? Most computers these days use binary arithmetic. This means that they can not store a number such as 10.11 exactly (or rather, they could store it exactly, but they don't) so as your input is not stored exactly you shouldn't expect exact results (from any computer arithmetic). You can use the format-number function to round the result to 2dp. > <xsl:variable name="SubTotals"> > <xsl:for-each select="/documents/value"> > <value><xsl:value-of select="." /></value> > </xsl:for-each> > </xsl:variable> don't do that, so this: <xsl:variable name="SubTotals" select="/documents/value"/> it's far more efficient and means that you would not need to use teh node-set() extension to do the sum. David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format