[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: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Thu, 26 Jul 2007 14:20:15 -0700
Re:  Rounding errors in financial app transforms
So if you try to round $100.105 to 2 decimal places you will get $100.11
whereas any financial system will (probably) expect $100.10.

If this IS the case you are going to have to force values at the tipping
point to go down not up.


Isn't this exactly what round-half-to-even($arg as numeric?, $precision as xs:integer) as numeric? is supposed to do?

http://www.w3.org/TR/xpath-functions/#func-round-half-to-even




-- Cheers, Dimitre Novatchev --------------------------------------- Truly great madness cannot be achieved without significant intelligence. --------------------------------------- To invent, you need a good imagination and a pile of junk ------------------------------------- You've achieved success in your field when you don't know whether what you're doing is work or play





On 7/26/07, W Charlton <XSLList@xxxxxxxxxx> wrote:
Justin,

It may be relevant to be aware that rounding in financial transactions is
not a simple mathematical problem, there is rounding and there is rounding.

Financial systems (at least all the ones we have dealt with) use have a
specific way or rounding money known as "bankers rounding" or "half even
rounding".

The problem value is the n.5. Most mathematics based system (and most
humans) including both versions of XSLT round to n+1.

Bankers however round to n-1. That way I presume they get to make more
money!!

So if you try to round $100.105 to 2 decimal places you will get $100.11
whereas any financial system will (probably) expect $100.10.

If this IS the case you are going to have to force values at the tipping
point to go down not up.

Does that shed some light on your problem?


William Charlton The yMonda team yMonda Limited w: www.ymonda.net

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.