You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-users@xalan.apache.org by mv...@amadeus.net on 2002/12/17 16:43:27 UTC
Strange result of multiplication
I am using the interim build of Xalan from 21/10 on HP-UX and found this
strange behavior:
XML:
<?xml version="1.0"?>
<Root Amount="2519.30">abc</Root>
XSL:
...
<xsl:template match="Root">
<xsl:element name="Amount">
<xsl:value-of select="@Amount*100"/>
</xsl:element>
</xsl:template>
Result:
<?xml version="1.0" encoding="UTF-8"?>
<Amount>251930.00000000003</Amount>
Any idea?
Cheers, Miro.
Re: Strange result of multiplication
Posted by David N Bertoni/Cambridge/IBM <da...@us.ibm.com>.
Hi Miro,
Remember, Xalan is doing floating point arithmetic here, so you may get
strange results as some numbers may not be representable in IEEE 754.
Previous releases of Xalan were cutting of precision at 6 decimal points,
which is not the right thing to do.
The best thing in cases were you want a particular precision is to build
Xalan with ICU integration and use the format-number() function.
Dave
mvasicek@amadeus
.net To: xalan-c-users@xml.apache.org
cc: (bcc: David N Bertoni/Cambridge/IBM)
12/17/2002 07:43 Subject: Strange result of multiplication
AM
I am using the interim build of Xalan from 21/10 on HP-UX and found this
strange behavior:
XML:
<?xml version="1.0"?>
<Root Amount="2519.30">abc</Root>
XSL:
...
<xsl:template match="Root">
<xsl:element name="Amount">
<xsl:value-of select="@Amount*100"/>
</xsl:element>
</xsl:template>
Result:
<?xml version="1.0" encoding="UTF-8"?>
<Amount>251930.00000000003</Amount>
Any idea?
Cheers, Miro.