178
ActionScript language elements
The first trace returns 2, rather than 12/5 or 2.4, because the modulo (
%
) operator returns
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
,
round (Math.round method)
%= modulo assignment operator
expression1
%=
expression2
Assigns
expression1
the value of
expression1
%
expression2
. The following two
statements are equivalent:
x %= y;
x = x % y;
Availability:
ActionScript 1.0; Flash Player 4 - In Flash 4 files, the
%
operator is expanded in
the SWF file as
x - int(x/y) * y
and may not be as fast or as accurate in later versions of
Flash Player.
Operands
expression1 : Number
- A number or expression that evaluates to a number.
expression2 : Number
- A number or expression that evaluates to a number.
Returns
Number
- The result of the arithmetic operation.
Example
The following example assigns the value
4
to the variable
x
:
var x:Number = 14;
var y:Number = 5;
trace(x = y); // output: 4
See also
% modulo operator
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...