# Operators

Operators combine sub-expressions to create more complex expressions. The general syntax for using operators is:

    Expression Operator Expression

ColdFusion has four types of operators:

- Arithmetic operators
- String operators
- Decision, or comparison, operators
- Boolean operators

## Arithmetic operators

Arithmetic Operators
Operator | Description
--- | ---
+, -, *, / | The basic arithmetic operators: addition, subtraction, multiplication, and division. In the case of division, the right operand cannot be zero.
+, - | Unary arithmetic operators for setting the sign of a number either positive or negative (+ or -).
MOD | Returns the remainder (modulus) after a number is divided by a divisor. The result has the same sign as the divisor. The right operand cannot be zero. For example, 11 MOD 4 is 3.
\ | Divides two integer values. Use the \ (trailing slash) to separate the integers. The right operand cannot be zero. For example, 9 \ 4 is 2.
^ | 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, 2 ^ 3 is 8.

The arithmetic operators are shown in the following table.

## String operators

String Operators
Operator | Description
--- | ---
& | Concatenates strings.

The is only one string operator, which is the concatenation operator.

## Decision, or comparison, operators

ColdFusion's decision, or comparison, operators produce a Boolean TRUE/FALSE.

Decision Operators
Operator | Description
--- | ---
IS | Performs a case-insensitive comparison of the two values and returns true if the values are identical.
IS NOT | Opposite behavior of is.
CONTAINS | Checks to see if the value on the left is contained in the value on the right and returns true if it is.
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 and returns true if it is.
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 and returns true if it is.
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 and returns true if it is.

### Shorthand notation for Boolean operators

You can replace some Boolean operators with shorthand notations to make your CFML more compact, as shown in the following table:

Shorthand Notation for Boolean Operators
Operator | Alternative name(s)
--- | ---
IS | EQUAL, EQ
IS NOT | NOT EQUAL, NEQ
CONTAINS | Not available
DOES NOT CONTAIN | Not available
GREATER THAN | GT
LESS THAN | LT
GREATER THAN OR EQUAL TO | GTE, GE
LESS THAN OR EQUAL TO | LTE, LE

## Boolean operators

Boolean, or Logical, operators perform logical connective and negation operations. The operands of Boolean operators are Boolean (TRUE/FALSE) values.

Boolean Operators
Operator | Description
--- | ---
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 of the arguments is TRUE; returns FALSE otherwise. For example, TRUE OR FALSE is TRUE, but FALSE OR FALSE is FALSE.
XOR | Exclusive or--either, or, but not both. Returns TRUE if the truth values of both arguments are different; returns FALSE otherwise. For example, TRUE XOR TRUE is FALSE, but TRUE XOR FALSE is TRUE.
EQV | Equivalence both true or both false. The EQV operator is the opposite of the XOR operator. For example, TRUE EQV TRUE is TRUE, but TRUE EQV FALSE is FALSE.
IMP | Implication. A IMP B is the truth value of the logical statement "If A Then B." A IMP B is FALSE only when A is TRUE and B is FALSE.