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

RE: Decimal precision

Subject: RE: Decimal precision
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 2 Feb 2005 20:49:01 -0000
decimal precision
With XSLT 2.0 

(a) a numeric literal such as 1.0 is interpreted as a decimal value

(b) you can force numbers to be treated as decimal values by casting

     e.g. xs:decimal($x)

(c) the result of an operation on two decimals, e.g. $x div $y, is itself
    a decimal (though with division, the precision is
implementation-defined)

(d) if you have a schema, and the schema defines the type of an element
    or attribute as decimal, then it's automatically treated as decimal
    without needing an explicit cast (like in (b)).

So summing a set of money amounts should give you the right answer without
any rounding errors.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Jim Neff [mailto:jneff@xxxxxxxxxxxxxxx] 
> Sent: 02 February 2005 20:17
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Decimal precision
> 
> Greetings,
> 
> I found Michael Kay's response to my same question here:
> 
> http://www.biglist.com/lists/xsl-list/archives/200412/msg00689.html
> 
> My problem is the same, but in Michael's response it sounds 
> like there is a
> way to get my XSLT version 2 stylesheet to use decimals 
> correctly.  Is this
> true?  If so, how is it different under version 2 than 1?
> 
> If not, then can someone please post an example of how to use the
> format-number() function to sum decimals correctly?
> 
> Thanks,
> Jim Neff

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.