% (modulo)

Availability

Flash Lite 1.0.

Usage

expression1 % expression2

Operands

expression1, expression2 Numbers or expressions that evaluate to numbers.

Description

Operator (arithmetic); calculates the remainder of expression1 divided by expression2. If an expression operand is non-numeric, the modulo operator attempts to convert it to a number. The expression can be a number or string that converts to a numeric value.

When targeting Flash Lite 1.0 or 1.1, the Flash compiler expands the % operator in the published SWF file by using the following formula:

expression1 - int(expression1/expression2) * expression2

The performance of this approximation might not be as fast or as accurate as versions of Flash Player that natively support the modulo operator.

Example

The following code shows a numeric example that uses the modulo (%) operator:

trace (12 % 5);        // output: 2
trace (4.3 % 2.1);        // output: 0.0999...