XPath/XSLT and extended precision

V

Vincent Lefevre

Hello,

The XPath 1.0 recommendation says:

A number represents a floating-point number. A number can have any
double-precision 64-bit format IEEE 754 value [IEEE 754]. These
include a special "Not-a-Number" (NaN) value, positive and negative
infinity, and positive and negative zero. See Section 4.2.3 of [JLS]
for a summary of the key rules of the IEEE 754 standard.

It doesn't say many things concerning the operations, but it seems that
it also requires them to conform to the IEEE-754 standard (as this is
the case for the division: "The div operator performs floating-point
division according to IEEE 754.").

Now my question: is extended precision allowed as the "destination"
format (where "destination" is defined in the IEEE-754 standard)?
i.e. computations would be performed with exact rounding to extended
precision, then rounded to double precision (hence the results would
be rounded twice).

This is what happens with xsltproc (libxslt) on x86 processors:

<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:eek:utput method="text" indent="no"/>

<xsl:template match="/">
<xsl:choose>
<xsl:when test="9007199254740992 + 1.00001 = 9007199254740992">
<xsl:text>equal</xsl:text>
</xsl:when>
<xsl:eek:therwise>
<xsl:text>different</xsl:text>
</xsl:eek:therwise>
</xsl:choose>
<xsl:text>
</xsl:text>
</xsl:template>

</xsl:stylesheet>

On an x86, the output is "equal", whereas on a PowerPC, it is
"different". So, is it a bug in libxslt or is it allowed by the
XPath recommendation?
 
D

Dimitre Novatchev

This is what happens with xsltproc (libxslt) on x86 processors:
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:eek:utput method="text" indent="no"/>

<xsl:template match="/">
<xsl:choose>
<xsl:when test="9007199254740992 + 1.00001 = 9007199254740992">
<xsl:text>equal</xsl:text>
</xsl:when>
<xsl:eek:therwise>
<xsl:text>different</xsl:text>
</xsl:eek:therwise>
</xsl:choose>
<xsl:text>
</xsl:text>
</xsl:template>

</xsl:stylesheet>

On an x86, the output is "equal", whereas on a PowerPC, it is
"different". So, is it a bug in libxslt or is it allowed by the
XPath recommendation?

I cannot reproduce your problem. xsltProc gives me: "different" on my
Pentium 4.



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 
V

Vincent Lefevre

Dimitre Novatchev said:
I cannot reproduce your problem. xsltProc gives me: "different" on my
Pentium 4.

Perhaps a different version for which the problem was fixed?
Here's mine:

greux:~> xsltproc --version
Using libxml 20508, libxslt 10030 and libexslt 720
xsltproc was compiled against libxml 20507, libxslt 10030 and libexslt 720
libxslt 10030 was compiled against libxml 20507
libexslt 720 was compiled against libxml 20507

FYI, this is the latest version of the Debian package (sid).
 
D

Dimitre Novatchev

Mine is:

Using libxml 20504, libxslt 10027 and libexslt 718
xsltproc was compiled against libxml 20504, libxslt 10027 and libexslt 718
libxslt 10027 was compiled against libxml 20504
libexslt 718 was compiled against libxml 20504



=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL
 
V

Vincent Lefevre

Dimitre Novatchev said:
Using libxml 20504, libxslt 10027 and libexslt 718
xsltproc was compiled against libxml 20504, libxslt 10027 and libexslt 718
libxslt 10027 was compiled against libxml 20504
libexslt 718 was compiled against libxml 20504

Older than mine. So, I've filled a bug on the Debian BTS, in case this
is a Debian(/unstable)-only bug.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XSLT Question 1
xslt and namespaces 2
Xpath and XSLT-transformation problem 1
XSLT problem 4
XSLT and XPath lookup problem 1
xslt / xpath question 3
XSLT Lookup Tables Help. 4
newbie XPath problem 2

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top