User Guide

NumberFormat 631
NumberFormat
Description
Creates a custom-formatted number value. Supports the numeric formatting used in the U.S. For
international number formatting, see
LSNumberFormat.
Returns
A formatted number value:
If no mask is specified, returns the value as an integer with a thousands separator.
If the parameter value is "" (an empty string), returns 0.
Category
Display and formatting functions
Function syntax
NumberFormat(number [, mask ])
See also
DecimalFormat, DollarFormat, IsNumeric, LSNumberFormat
History
ColdFusion MX: Changed behavior: if the mask format cannot correctly mask a number, this
function returns the number unchanged. (It does not truncate the number nor throw an error.)
(If no mask is selected, ColdFusion MX rounds the decimal part as ColdFusion 5 does. For
example, it rounds 34.567 to 35.)
Parameters
The following table explains mask characters:
Parameter Description
number A number.
mask A string or a variable that contains one. Set of characters that determine how
ColdFusion displays the number
Mask character Meaning
_ (underscore) Optional. Digit placeholder.
9 Optional. Digit placeholder. (Shows decimal places more clearly than _.)
. Location of a mandatory decimal point.
0 Located to the left or right of a mandatory decimal point. Pads with zeros.
( ) If number is less than zero, puts parentheses around the mask.
+ Puts plus sign before positive number; minus sign before negative number.
- Puts a space before positive number; minus sign before negative number.
, Separates every third decimal place with a comma.
L,C Left-justifies or center-justifies number within width of mask column. First
character of mask must be L or C. Default: right-justified.