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

RE: single precision bug

Subject: RE: single precision bug
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Tue, 17 Aug 2004 14:20:38 +0100
sql precision cents
> A better inspection learns me that the XSLT processor makes a 
> mistake here
> totalDebit - sum(./debitAmount) gives me a value of:
> 
> -0.00000000005820766091346741 whereas this should be 0.
> 
> MsXML, Saxon,Xalan, XT all have this error only Sablotron returns the
> correct value.
> 
> What do you all think of this?
> 

Since the XSLT/XPath specification is very precise about how numeric
arithmetic should work, it's more likely that MSXML, Saxon, Xalan, and xt
are getting it right and Sablotron is getting it wrong.

Generally, floating point arithmetic is likely to involve rounding errors
when converting between decimal and binary representations. Ideally you
would do this arithmetic in decimal (you can do this in 2.0). Alternatively,
try converting the amounts to pence/cents by multiplying by 100 and
rounding, before doing the arithmetic comparison.

Michael Kay

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.