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

Re: format-number/bankers' rounding problem

Subject: Re: format-number/bankers' rounding problem
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 13 Jul 2011 19:15:48 +0100
Re:  format-number/bankers' rounding problem
On 13/07/2011 17:59, daniel whitney wrote:
I saw round-half-to-even but I actually want to round up for positive
and down for negative values. Of course I should have put that at the
very beginning of my post.

hmm wikipedia agrees with me that "bankers rounding" is half-even but whatever, so I think you want


if($n gt 0) then round($n) else (- round(-$n))

assuming you just mean 0.5 goes up or down. If you want all fractional parts to round up if positive and down if negative replace both round() with ceiling() in the above.


David


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.