Adobe COLDFUSION 9 Manual page 70

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
Operator types
ColdFusion has Five types of operators:
• Arithmetic
• Boolean
• Decision (or comparison)
• String
• Ternary
Functions also can be viewed as operators because they act on operands.
Arithmetic operators
The following table describes the arithmetic operators:
Operator
Description
+ - * /
Basic arithmetic: Addition, subtraction, multiplication, and division.
In division, the right operand cannot be zero.
++ --
Increment and decrement. Increase or decrease the variable by one.
These operators can be used for pre-incrementing or decrementing (as in
changed before it is used in the expression. They can also be used for post-incrementing or decrementing (as in
x = i++
for example, the value of
cases, the value of
These operators cannot be used with expressions that involve functions, as in
expression such as
parentheses to group the operators, as in
+= -= *= /= %=
Compound assignment operators. The variable on the right is used as both an element in the expression and the
result variable. Thus, the expression
An expression can have only one compound assignment operator.
+ -
Unary arithmetic: Set the sign of a number.
MOD
Modulus: Return the remainder after a number is divided by a divisor. The result has the same sign as the divisor.
The value to the right of the operator should be an integer; using a non-numeric value causes an error, and if you
or %
specify a real number, ColdFusion ignores the fractional part (for example, 11 MOD 4.7 is 3).
\
Integer division: Divide an integer by another integer. The result is also an integer; for example, 9\4 is 2. The right
operand cannot be zero.
^
Exponentiation: Return the result of a number raised to a power (exponent). Use the caret character (^) to
separate the number from the power; for example, 2^3 is 8. Real and negative numbers are allowed for both the
base and the exponent. However, any expression that equates to an imaginary number, such -1^.5 results in the
string "-1.#IND. ColdFusion does not support imaginary or complex numbers.
Boolean operators
Boolean, or logical, operators perform logical connective and negation operations. The operands of Boolean operators
are Boolean (True/False) values. The following table describes the Boolean operators:
), where the value is changed after it is used in the expression. If the value of the variable
x
in
x = ++i
is 8 after expression evaluation, but in
i
becomes 8.
-++x
, but
---x
and
+++x
-(--x)
a += b
Last updated 8/5/2010
x = ++ i
x=i++
f().a++
cause errors, because their meanings are ambiguous. You can use
or
+(++x)
, however.
is equivalent to
a = a +b
.
65
), where the variable is
i
is initially 7,
, the value of
x
is 7. In both
. Also, you can use an

Advertisement

Table of Contents
loading

Table of Contents