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">
<xslutput method="text" indent="no"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="9007199254740992 + 1.00001 = 9007199254740992">
<xsl:text>equal</xsl:text>
</xsl:when>
<xsltherwise>
<xsl:text>different</xsl:text>
</xsltherwise>
</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?
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">
<xslutput method="text" indent="no"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="9007199254740992 + 1.00001 = 9007199254740992">
<xsl:text>equal</xsl:text>
</xsl:when>
<xsltherwise>
<xsl:text>different</xsl:text>
</xsltherwise>
</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?