Operators fall into four category types:
Frequently used when coding conditional logic.
Frequently used when coding conditional logic.
For examples and usage information, refer to Chapters 6 and 8 of Developing Web Applications with ColdFusion Express.
The table below describes operators by type and symbol.
| Type | Symbol | Description |
|---|---|---|
| Arithmetic | +, -, *, / | Add, subtract, multiply, and divide. In the case of division, the right operand cannot be zero. For example, |
| \ | Divides two integer values and returns a whole number. For example, | |
| ^ | Returns the result of a number raised to a power (exponent). Use the ^ (caret) to separate the number from the power. The left operand cannot be zero. For example, | |
| MOD | Returns the remainder (modulus) after a number is divided. The result has the same sign as the divisor. The right operand cannot be zero. For example, | |
| + or - | Set a number to either positive or negative. For example, | |
| String | & | Concatenates text strings including those returned from variables and functions. |
| Comparison | IS |
Performs a case-insensitive comparison of two values.
Returns true or false.
For example, this code tests for equal values. The condition is true only if the FirstName value is Jeremy. <CFIF Form.FirstName IS "Jeremy"> |
| IS NOT |
Opposite behavior of IS.
For example, this code tests for inequal values. The condition is true only if the FirstName value is not Jeremy.
<CFIF Form.FirstName IS NOT "Jeremy"> | |
| CONTAINS |
Checks to see if the value on the left is contained in the value on the right.
Returns true or false.
For example this code tests for a value condition. The condition is true only if the FirstName value contains Jeremy. <CFIF Form.FirstName CONTAINS "Jeremy"> | |
| DOES NOT CONTAIN | Opposite behavior of CONTAINS. | |
| GREATER THAN | Checks to see if the value on the left is greater than the value on the right. Returns true or false. | |
| LESS THAN | Opposite behavior of GREATER THAN. | |
| GREATER THAN OR EQUAL TO | Checks to see if the value on the left is greater than or equal to the value on the right. Returns true or false. | |
| LESS THAN OR EQUAL TO | Checks to see if the value on the left is less than or equal to the value on the right. Returns true or false. | |
| Compound Boolean | NOT | Reverses the value of an argument. For example, NOT TRUE is FALSE and vice versa. |
| AND | Returns true if both arguments are true; returns false otherwise. For example, TRUE AND TRUE is true, but TRUE AND FALSE is false. | |
| OR | Returns true if any argument is TRUE and returns false otherwise. For example, TRUE OR FALSE is true, but FALSE OR FALSE is false | |
| XOR |
Returns TRUE if either argument is (exclusively) TRUE.
For example, TRUE XOR TRUE is FALSE, but TRUE XOR FALSE is TRUE.
| |
| EQV |
Returns TRUE if both arguments are TRUE or both are FALSE (Equivalent).
The EQV operator is the opposite of the XOR operator.
For example, TRUE EQV TRUE is TRUE, but TRUE EQV FALSE is FALSE.
|