Whatever message this page gives is out now! Go check it out!
LSNumberFormat(number [, mask, locale])Parameter | Description |
number | Number to format |
mask | LSNumberFormat mask characters apply, except: dollar sign, comma, and dot are mapped to their locale-specific equivalents. |
locale | Locale to use instead of the locale of the page when processing the function |
Character | Meaning |
_ | (Underscore.) Digit placeholder. |
9 | Digit placeholder. (Shows decimal places more clearly than _ .) |
. | Location of a mandatory decimal point (or locale-appropriate symbol). |
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 space before positive number; minus sign before negative number. |
, | Separates every third decimal place with a comma (or locale-appropriate symbol). |
L,C | Left-justifies or center-justifies number within width of mask column. First character of mask must be L or C. The default value is right-justified. |
$ | Puts a dollar sign (or locale-appropriate symbol) before formatted number. First character of mask must be the dollar sign ($). |
^ | Separates left and right formatting. |
Number | Mask | Result |
4.37 | $ ._ | "$ 4.37" |
4.37 | $_._ | " $4.37" |
Number | Mask | Result |
-4.37 | - ._ | "- 4.37" |
-4.37 | -_._ | " -4.37" |
Number | Mask | Result |
3.21 | C(_^_) | "( 3.21 )" |
3.21 | C_(^_) | " (3.21 )" |
3.21 | C(_^)_ | "( 3.21) " |
3.21 | C_(^)_ | " (3.21) " |
<h3>LSNumberFormat Example</h3>
<p>LSNumberFormat returns a number value using the locale convention.
<!--- loop through a list of locales and show number values --->
<cfloop LIST = "#Server.Coldfusion.SupportedLocales#"
index = "locale" delimiters = ",">
<cfset oldlocale = SetLocale(locale)>
<cfoutput><p><b><i>#locale#</i></b><br>
#LSNumberFormat(-1234.5678, "
")#<br>
#LSNumberFormat(-1234.5678, "
.
")#<br>
#LSNumberFormat(1234.5678, "
")#<br>
#LSNumberFormat(1234.5678, "
.
")#<br>
#LSNumberFormat(1234.5678, "$_(
.
)")#<br>
#LSNumberFormat(-1234.5678, "$_(
.
)")#<br>
#LSNumberFormat(1234.5678, "+
.
")#<br>
#LSNumberFormat(1234.5678, "-
.
")#<br>
</cfoutput>
</cfloop>