MACROMEDIA COLDFUSION MX 61-CFML Reference page 633

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

Advertisement

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.
To set the default display format of date, time, number, and currency values, use the
SetLocale
function.
Example
<h3>NumberFormat Example</h3>
<cfloop FROM = 1000 TO = 1020 INDEX = "counter">
<cfset CounterRoot2 = counter * sqr(2)>
<!--- Show result in default format, adding comma for thousands place;
and in custom format, displaying to two decimal places --->
<cfoutput>
<pre>#counter# * Square Root of 2: #NumberFormat(CounterRoot2,
'_____.__')#</pre>
<pre>#counter# * Square Root of 2: #NumberFormat(CounterRoot2)#</pre>
</cfoutput>
</cfloop>
NumberFormat
633

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents