RE: [xsl] decimal vs double value spaces

Subject: RE: [xsl] decimal vs double value spaces
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 5 Nov 2009 11:49:01 -0000
The value space of xs:double is fully defined in the spec, based on IEEE
specifications.

The value space of xs:decimal isn't fully defined, in that limits on the
number of digits are implementation-defined. However, every value in the
xs:decimal value space is a multiples of 10^-n where n is
implementation-defined, and so long as you're within the expected number of
digits, decimal arithmetic should be exact, whereas double arithmetic in
general will involve rounding on input and output (that is, conversion from
string->double and from double->string).

> but note that some (possibly 
> unfinished/ possibly naive) Java XPath engines internally 
> represent xs:decimal and xs:double as Java doubles 

Representing xs:decimal using Java doubles will give completely
non-conformant results which I don't think can be justified by any appeal to
the implementation-defined limits on precision.

Regards,

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

Current Thread