xsl-list
[Top] [All Lists]

RE: Avoid rounding up/down in format-number function

2004-01-02 11:02:43

is there a way to avoid rounding up/down in the 
format-number() function?


format-number() is obliged to fit the number in the the space provided:
if your picture is "0.00##" then you will have at least two and at most
four digits after the decimal point.

That leaves the question of how the rounding is done. XSLT 1.0 specifies
the function in terms of the JDK 1.1 specification of DecimalFormat, and
the JDK 1.1 spec is notoriously vague. Later versions of the JDK have
specified that the rounding is "half-even" (i.e. 0.35 rounds to 0.4,
while 0.25 rounds to 0.2), but XSLT 1.0 processors are not obliged to
respect that.

Michael Kay


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



<Prev in Thread] Current Thread [Next in Thread>