Evaluation And Type Conversion Issues - MACROMEDIA COLDFUSION MX 61-DEVELOPING COLDFUSION MX Develop Manual

Developing coldfusion mx applications
Table of Contents

Advertisement

Converting binary data
ColdFusion cannot automatically convert binary data to other data types. To convert binary data,
use the
ToBase64
Base64 encoding" on page
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
,
, and
Round
Fix
of the fractional part of the number.
If you use a hidden form field with a name that has the suffix
form input field, 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
validate a form input 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.

Evaluation and type conversion issues

The following sections explain several issues that you might encounter with type evaluation and
conversion.
Comparing variables to True or False
You might expect the following two
<cfif myVariable>
<cfoutput>myVariable equals #myVariable# and is True
</cfoutput>
</cfif>
<cfif myVariable IS True>
<cfoutput>myVariable equals #myVariable# and is True
</cfoutput>
</cfif>
and
functions. For more information, see
ToString
60.
functions convert real numbers to integers, and differ in their treatment
Ceiling
cfif
_integer
_integer
tag examples to produce the same results:
"Binary data type and
Int
or
to validate a
_range
,
, or
_float
_range
Data type conversion
,
to
69

Advertisement

Table of Contents
loading

This manual is also suitable for:

Coldfusion mx

Table of Contents