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

RE: Avoid rounding up/down in format-number function

Subject: RE: Avoid rounding up/down in format-number function
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Fri, 2 Jan 2004 18:02:43 -0000
xsl rounding
> 
> is there a way to avoid rounding up/down in the 
> format-number() function?
> 

format-number() is obliged to fit the number in the the space provided:
if your picture is "0.00##" then you will have at least two and at most
four digits after the decimal point.

That leaves the question of how the rounding is done. XSLT 1.0 specifies
the function in terms of the JDK 1.1 specification of DecimalFormat, and
the JDK 1.1 spec is notoriously vague. Later versions of the JDK have
specified that the rounding is "half-even" (i.e. 0.35 rounds to 0.4,
while 0.25 rounds to 0.2), but XSLT 1.0 processors are not obliged to
respect that.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.