RE: [xsl] XSLT 2.0 Decimal number silliness

Subject: RE: [xsl] XSLT 2.0 Decimal number silliness
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 25 Mar 2004 19:12:10 -0000
# Two possibilities.  One is to allow some way to specify 
# default number of fraction digits in the absence of a schema. 
#  Another is to implement a fixed precision and document it.  
# I have chosen to implement 18 integer digits plus 18 fraction 
# digits.  I believe this is legitimate according to the spec 
# (tell me if I'm wrong), and it's a whole lot easier to 
# explain to users.  Plus, you get exactly the same answers no 
# matter how you calculate two-thirds in my examples below.

The schema spec says that a total of 18 digits in total is sufficient (both
for xs:integer and for xs:decimal). However, xs:unsignedLong requires 20
digits, and that's derived by restriction from xs:integer, so I don't know
where the 18 came from.

My implementation is using infinite precision for xs:decimal, which is why I
have to make some kind of cut-off on division. Another option I considered
was to keep max(18, M, N) significant digits where M and N are the number of
significant digits in the operands.

I tend to agree with you that I would much rather have an interoperable spec
on this. However, some of the XQuery vendors push hard against this,
especially those who are trying to translate XPath predicates into SQL
predicates.

Michael Kay

Current Thread