Adobe 38043740 - ColdFusion Standard - Mac Development Manual page 58

Developing applications
Hide thumbs Also See for 38043740 - ColdFusion Standard - Mac:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
The cfoutput tag
The
tag always displays data as a string. As a result, when you display a variable using the
cfoutput
ColdFusion applies the type conversion rules to any non-string data before displaying it. For example, the
tag displays a date-time value as an ODBC timestamp.
Case-insensitivity and Boolean conversion
Because ColdFusion expression evaluation is not case sensitive, Yes, YES, and yes are equivalent; False, FALSE, and
false are equivalent; No, NO, and no are equivalent; and True, TRUE, and true are equivalent.
Converting binary data
ColdFusion cannot automatically convert binary data to other data types. To convert binary data, use the
and
functions. For more information, see
ToString
Converting date and time data
To ensure that a date and time value is expressed as a real number, add zero to the variable. The following example
shows this:
<cfset mynow = now()>
Use cfoutput to display the result of the now function:<br>
<cfoutput>#mynow#</cfoutput><br>
Now add 0 to the result and display it again:<br>
<cfset mynow = mynow + 0>
<cfoutput>#mynow#</cfoutput>
At 1:06 PM on June 6, 2003, its output looked like this:
Use cfoutput to display the result of the now function:
{ts '2003-06-03 13:06:44'}
Now add 0 to the result and display it again:
37775.5463426
Converting numeric values
When ColdFusion evaluates an expression that includes both integers and real numbers, the result is a real number.
To convert a real number to an integer, use a ColdFusion function. The
convert real numbers to integers, and differ in their treatment of the fractional part of the number.
If you use a hidden form field with a name that has the suffix _
ColdFusion truncates real numbers entered into the field and passes the resulting integer to the action page.
If you use a hidden form field with a name that has the suffix _
field, and the entered data contains a dollar amount (including a dollar sign) or a numeric value with commas,
ColdFusion considers the input to be valid, removes the dollar sign or commas from the value, and passes the resulting
integer or real number to the action page.
ColdFusion does not have an inherent data type for arbitrary precision decimal numbers (BigDecimal numbers).
ColdFusion initially saves such numbers as strings, and if you use them in an expression, converts the value to a
numeric type, often losing precision. You can retain precision by using the
evaluates string expressions using BigDecimal precision arithmetic and can return the result as a long string of
numbers. For more information, see PrecisionEvaluate in the CFML Reference.
Evaluation and type conversion issues
The following sections explain several issues that you can encounter with type evaluation and conversion.
"Binary data type and binary
Int
or _
integer
, _
integer
Last updated 1/20/2012
cfoutput
encoding" on page 45.
,
,
, and
Round
Fix
Ceiling
to validate a form input field,
range
, or _
to validate a form input
float
range
method, which
PrecisionEvaluate
53
tag,
cfoutput
ToBase64
functions

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion 9

Table of Contents