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

Re: Rounding errors in financial app transforms

Subject: Re: Rounding errors in financial app transforms
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Thu, 26 Jul 2007 15:07:02 +0200
Re:  Rounding errors in financial app transforms
Hi Justin,

I've to pointers that I am thinking of, but I don't know if this is what you're after: Have you considered using xs:decimal? Just as an example:

xs:float(10.1) - xs:float(9.93) = 0.17000008
xs:double(10.1) - xs:double(9.93) = 0.16999999999999993
xs:decimal(10.1) - xs:decimal(9.93) = 0.17

Ok, this is just a simple example. Rounding errors can occur in a number of ways and I am not aware of your application and how that is normally done. But then, still, how about the added functionality for rounding in XSLT 2.0? Like: fn:round-half-to-even()?

Cheers,
-- Abel Braaksma



Justin Johansson wrote:
What's the recommended recipe to avoid rounding-error discrepancies
in financial applications based upon XSLT (2.0) transforms?

Having demonstrated a proof-of-concept for an application based on XSLT 2.0
to a commercial finance/accounting industry client (to replace a legacy system
which happens to be written in CBASIC-86), a stumbling block / annoyance is
the
accumulation of one cent errors in the aggregated results.

This, of course, is as a result of using floating-point arithmetic in XSLT.

BCD arithmetic is apparently still used in mainframe applications, as was in
CBASIC-86, but most latter-day languages including XSLT seem to have
ignored it.

Does this means that one needs to resort to doing non-trivial financial
apps in XSLT
in integer arithmetic?

My guess is that even having a standard MulDiv function in XSLT would help
matters floating-point-wise but sadly there is no such animal available.

Thanks to all for suggestions.

Justin Johansson

*** A horse with no name is called Lambda ***

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.