Subject: [xsl] round-half-to-even problem. From: "Szabo, Patrick \(LNG-VIE\)" <patrick.szabo@xxxxxxxxxxxxx> Date: Mon, 24 Jan 2011 15:39:58 +0100 |
Hi, I'm using saxon 9 EE and xslt 2.0. I want to round but I'm getting weird outputs. My Template looks like this: <xsl:template match="data"> <absatz> <xsl:choose> <xsl:when test="@type='Number' and string-length(substring-after(., '.')) > 2"> <xsl:value-of select="round-half-to-even(text(), 2)"/> </xsl:when> <xsl:otherwise> <xsl:apply-templates/> </xsl:otherwise> </xsl:choose> </absatz> </xsl:template> Example: <data type="Number">1351.845</data> Output: <absatz>1351.84</absatz> Desired: <absatz>1351.85</absatz> Example: <data type="Number">298.15499999999997</data> Output: <absatz>298.16</absatz> <- which is correct or at least what I want. Can anybody explain this to why on time it takes the bigger and the next time the smaller number ?! Can I control that somehow ?! kind regards . . . . . . . . . . . . . . . . . . . . . . . . . . Patrick Szabo XSLT-Entwickler LexisNexis Marxergasse 25, 1030 Wien mailto:patrick.szabo@xxxxxxxxxxxxx Tel.: +43 (1) 534 52 - 1573 Fax: +43 (1) 534 52 - 146
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Text based stage play scr, Jacobus Reyneke | Thread | Re: [xsl] round-half-to-even proble, G. Ken Holman |
Re: [xsl] Text based stage play scr, Jacobus Reyneke | Date | Re: [xsl] round-half-to-even proble, G. Ken Holman |
Month |