Modulo Operator; Modulo Assignment Operator - MACROMEDIA FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE Reference

Flash lite 2.x actionscript language reference
Hide thumbs Also See for FLASH 8-FLASH LITE 2.X ACTIONSCRIPT LANGUAGE:
Table of Contents

Advertisement

% modulo operator

expression1 % expression2
Calculates the remainder of
parameters are non-numeric, the modulo (
expression
to numbers. The
expression
The sign of the result of modulo operation matches the sign of the dividend (the first
number). For example,
Availability: ActionScript 1.0; Flash Lite 1.0 - In Flash 4 files, the
the SWF file as
x - int(x/y) * y
Flash Player.
Operands
expression1 :
Number
expression2 :
Number
Returns
- The result of the arithmetic operation.
Number
Example
The following numeric example uses the modulo (
trace(12%5); // traces 2
trace(4.3%2.1); // traces 0.0999999999999996
trace(4%4); // traces 0
The first trace returns 2, rather than 12/5 or 2.4, because the modulo (
only the remainder. The second trace returns 0.0999999999999996 instead of the expected
0.1 because of the limitations of floating-point accuracy in binary computing.
See also
/ division operator

%= modulo assignment operator

expression1 %= expression2
Assigns
expression1
statements are equivalent:
x %= y; and x = x % y;
164
ActionScript language elements
expression1
can be a number or string that converts to a numeric value.
and
-4 % 3
-4 % -3
and may not be as fast or as accurate in later versions of
- A number or expression that evaluates to a number.
- A number or expression that evaluates to a number.
,
round (Math.round method)
the value of
expression1 % expression2
divided by
expression2
) operator attempts to convert them
%
both evaluate to
-1
operator:
%)
. If either of the
.
operator is expanded in
%
) operator returns
%
. The following two

Advertisement

Table of Contents
loading

Table of Contents