Name
NumberFormat
Synopsis
NumberFormat(number
[,mask
])
Returns number
formatted according to
mask
. If no value is specified for
mask
, NumberFormat
returns number
as an integer formatted
with thousands separators. Valid entries for
mask
are:
Mask |
Description |
---|---|
_ |
Optional digit placeholder |
9 |
Optional digit placeholder; same as |
. |
Decimal point location |
0 |
Forces padding with zeros |
( ) |
Surrounds negative numbers in parentheses |
+ |
Places a plus sign in front of positive numbers and a minus sign in front of negative numbers |
- |
Places a space in front of positive numbers and a minus sign in front of negative numbers |
, |
Separates thousands with commas |
L |
Left-justifies the number within the width of the mask |
C |
Centers the number within the width of the mask |
$ |
Places a dollar sign in front of the number |
^ |
Separates left from right formatting |
Examples:
<CFSET MyNumber = 1000.99> <CFOUTPUT> <B>MyNumber = #MyNumber#</B> <P> NumberFormat(MyNumber, '____'): #NumberFormat(MyNumber, '____')#<BR> NumberFormat(MyNumber, '9999.99'): #NumberFormat(MyNumber, '9999.99')#<BR> NumberFormat(MyNumber, '09999.9900'): #NumberFormat(MyNumber, '09999.9900')#<BR> NumberFormat(-MyNumber, '(9999.99)'): #NumberFormat(-MyNumber, '(9999.99)')#<BR> NumberFormat(MyNumber, '+9999.99'): #NumberFormat(MyNumber, '+9999.99')#<BR> NumberFormat(-MyNumber, '+9999.99'): #NumberFormat(-MyNumber, '+9999.99')#<BR> NumberFormat(MyNumber, '-9999.99'): #NumberFormat(MyNumber, ...
Get Programming ColdFusion now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.