MACROMEDIA COLDFUSION MX 61-CFML Reference page 612

Cfml reference
Hide thumbs Also See for COLDFUSION MX 61-CFML:
Table of Contents

Advertisement

Number
3.21
3.21
To set the default display format of date, time, number, and currency values, use the
function.
When converting from string to double, to prevent rounding errors, this function adds a
rounding factor of 1.5543122344752E-014 to the converted number. For example, without
adding the rounding factor, converting the string value 1.275 to double with two digits of
precision results in a value of 1.27499999999999999, which would be rounded up to 1.27. By
adding the rounding factor, the conversion correctly results in a value of 1.28.
If you round off a double, such as 1.99499999999999999999999999999, where the last decimal
is 10E-14, the rounding factor can cause an incorrect result.
Example
<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>
612
Chapter 3: ColdFusion Functions
Mask
Result
C(__^)__
"( 3.21) "
C__(^)__
" (3.21) "
SetLocale

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents