You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xalan.apache.org by Sam Prokop <sp...@4tek.de> on 2006/08/09 14:33:18 UTC

format-number round and negative

Hi all,

i´ve got the following problem:

if i use format-number and use formatting-pattern ###.##0,0 
with this decimal-format definition:

<xsl:decimal-format name="standard" decimal-separator="," grouping-separator="." infinity="Infinity" minus-sign="-" NaN="NaN" percent="%" per-mille="&#x2030;" zero-digit="0" digit="#" pattern-separator=";"/>

i get -0,0 if the input-xml has the value -0.03, i expected 0,0 and 
i get -0,0 if the input-xml has the value -0.05, i expected -0,1

msxml does what i expect, but i won´t use that one.


So, is this behavior of xalan a bug or a feature? and is there a work-around?

Thanks in anticipation

Sam



Re: format-number round and negative

Posted by ke...@us.ibm.com.
I think the expected behavior is the IEEE 754 round-to-nearest rule, which
I *think* says that if two equally good choices exist, the one closer to
positive infinity will be taken.

One classic workaround is to take absolute value, round, then restore the
sign...


______________________________________
"... Three things see no end: A loop with exit code done wrong,
A semaphore untested, And the change that comes along. ..."
  -- "Threes" Rev 1.1 - Duane Elms / Leslie Fish
(http://www.ovff.org/pegasus/songs/threes-rev-11.html)