dongzhilian0188 2011-11-22 14:41
浏览 37

XSL:负数是四舍五入的,但不是正数

In XSL I get strange behavior. I do use number-format but what is strange that when I run data through I get correct number when I have positive number (float) (123,45 returns as 123.45) but if I have a negative number (float) then it gets rounded (-123,45 returns as -123,5)

Is there anybody out there that knows what I can do to fix this so that the negative number will not be rounded?


I use PHP to calculate the number.

XSL code is:

<xsl:decimal-format name="european" decimal-separator=',' grouping-separator='.' NaN="" />    
<xsl:value-of select="format-number(number, '###.###,00','european')"/>

When I sent in: -123.45 XSL printed out: -123.40

When I sent in: "-123.45" (or --> (string)$number; <-- where $number is a float) XSL printed out: -123.45

So the problem I had was that when I was calculating the positive number it returned me a string formatted text but in the negative formula I got a float formatted text from the PHP script.

Maybe I could have solve it on the XSL side with some changes to the format-number code so that XSL would not round of my numbers - any ideas how I can do that?

  • 写回答

0条回答 默认 最新

    报告相同问题?