RE: [xsl] format-number incorrectly formatting number (using fop 0.91beta)

Subject: RE: [xsl] format-number incorrectly formatting number (using fop 0.91beta)
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 18 Apr 2006 12:34:56 +0100
It might well be that the error is not introduced by format-number, but by
the string-to-double conversion used when the number is read in the first
place. You're at the limit of the range of precision that double-precision
floating point can handle.

To investigate further however, one needs to know which XSLT processor you
are using! (Probably Xalan, if you're using FOP, unless you specify
otherwise).

For large numbers like this I suggest you switch to XSLT 2.0 and xs:decimal.
Saxon's implementation of xs:decimal handles arbitrary-precision formatting
and arithmetic.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: Ian & Chris [mailto:bakeric@xxxxxxxxxxxxxxx]
> Sent: 18 April 2006 11:28
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] format-number incorrectly formatting number (using fop
> 0.91beta)
>
> Hi all,
>
>  I am currently trying to format a large number (19v2) in a report, the
> format-number function seems to do incorrect formatting when it deals with
> large numbers, and an example follows:
>
> <xsl:value-of select='format-number(-34567890123456787.00,"###,###.00
> ;###,###.00CR")'/>
>
> In the above example the number should read
>
> 34,567,890,123,456,787.00CR
>
> But when it formats it is set to:
>
> 34,567,890,123,456,788.00CR
>
>
> Any ideas, OK it is a large number, and you might say well you would never
> use this, but, in insurance companies in Indonesia the numbers for
> re-insurance in the local currency (rupiah). It may get to many billions
> for
> a year.
>
>
> Thanks, Ian

Current Thread