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 |
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 MX, 2nd Edition 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.