Next / Previous / Contents / TCC Help System / NM Tech homepage

12.3. format-number(): Convert a number to a string

This function takes two required arguments and a third optional argument:

    format-number(n, p [,f])



is the number to be formatted


is a format pattern string using the characters described below


if supplied, this is the name of a named <xsl:decimal> format item that will be used to determine internationalization features of the formatting, such as the grouping separator.

Here are the characters used in the formatting pattern p:

Table 1. Format pattern characters for format-number()

#Denotes a digit. Leading and trailing zeroes (and a trailing decimal, if any) will disappear.
0Denotes a digit, but a digit always appears, even if it is a zero.
-Shows the position of the minus sign.
.Shows the position of the decimal point.
,Positions the grouping separator for thousands. For example, "##,###.00".
%Multiplies the number by one hundred and displays it as a percentage.
;You can supply two patterns separated by a semicolon; the first one will be used for positive numbers and the second for negative numbers.
otherLiteral characters are carried through to the result.