xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James Melton <james.mel...@cylogix.com>
Subject Re: Rounding (was: Strange XSLT behaviour)
Date Thu, 12 Apr 2001 22:08:20 GMT
<2cents>
That sounds reasonable until you try to put it into practice with a
simple format like '#.00'. You have to do some awkward arithmetic in
order to use round, floor, or ceiling and finish with two decimal
digits. Although the spec seems reasonable in deferring to the behavior
of the JDK, DecimalFormat does not seem to document well what is does
with the extra decimal places. I think the spec is therefore a bit
shortsighted on this item.
</2cents>

Jim.

David_Marston@lotus.com wrote:
> 
> Robert Stuart wrote:
> >The argument should not be "is this rounding rule correct?", but
> >"please, may we have a selection of rounding rules".
> 
> But the original question was:
> <xsl:value-of select="format-number(9.5,'00')"/> gives "10" and
> <xsl:value-of select="format-number(10.5,'00')"/> also gives 10.
> 
> My answer is:
> If you need to control rounding, do it yourself rather than trusting
> format-number. For example,
> <xsl:value-of select="format-number(floor(9.5),'00')"/>
> Think of format-number as being more about commas and leading zeroes
> than about numeric alteration.
> .................David Marston
> 
> ---------------------------------------------------------------------
> In case of troubles, e-mail:     webmaster@xml.apache.org
> To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
> For additional commands, e-mail: general-help@xml.apache.org

-- 

____________________________________________________________
James Melton                 CyLogix
609.750.5190                 609.750.5100
james.melton@cylogix.com     www.cylogix.com

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message