[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
My guess is you got 7.00000000000000001 or 6.9999999999999. This is because binary representation of some decimals using standard techniques is impossibe, similarly to expressing one third in decimal.
You either have to use integer arithmetic, in this case '100 * 7 div 100' or round your answers.
Joe (MVP - xml)
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Re: [xsl] Magic numbers
Subject: Re: [xsl] Magic numbers From: "Joe Fawcett" <joefawcett@xxxxxxxxxxx> Date: Tue, 18 Nov 2003 13:47:13 +0000 |
As you don't say what your results were who knows?From: Yago Alvarado <Yago.Alvarado@xxxxxxxxxxxxxx> Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: "'XSL-List@xxxxxxxxxxxxxxxxxxxxxx'" <XSL-List@xxxxxxxxxxxxxxxxxxxxxx> Subject: [xsl] Magic numbers Date: Tue, 18 Nov 2003 12:54:49 -0000
Hi everyone!
I have the following xsl code:
<?xml version="1.0"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/>
<xsl:template match="/"> <xsl:value-of select="100 * .05"/> </xsl:template>
</xsl:stylesheet>
which works fine and shows the expected result... now...if you change .05 for .07 you get something totally unexpected (at least is unexpected to me).
My first thought was blaming the XSLT processor so I tried with another one... and I'm getting the same result whatever the processor is... (MSXML 4 or Saxon 6.5.2)
This only happens using the *magic* number of 7 with any other number it
works just fine and returns the expected result.
Does anyone know why this is happening? Is is number 7 a truly magical number with undiscovered mathematical powers or is it just me not understanding what's going on here? (my vote goes to the second one) ;-)
Regards, Yago
My guess is you got 7.00000000000000001 or 6.9999999999999. This is because binary representation of some decimals using standard techniques is impossibe, similarly to expressing one third in decimal.
You either have to use integer arithmetic, in this case '100 * 7 div 100' or round your answers.
Joe (MVP - xml)
_________________________________________________________________
Tired of 56k? Get a FREE BT Broadband connection http://www.msn.co.uk/specials/btbroadband
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Magic numbers, David Carlisle | Thread | RE: [xsl] Magic numbers, Yago Alvarado |
Re: [xsl] Knowing if a node has chi, David Carlisle | Date | Re: [xsl] using xalan parser to pro, Joseph Kesselman |
Month |