03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

See also<br />

|| logical OR operator, | bitwise OR operator<br />

% modulo operator<br />

expression1 % expression2<br />

Calculates the remainder of expression1 divided by expression2. If either of the<br />

expression parameters are non-numeric, the modulo (%) operator attempts to convert them<br />

to numbers. The expression can be a number or string that converts to a numeric value.<br />

The sign of the result of modulo operation matches the sign of the dividend (the first<br />

number). For example, -4 % 3 <strong>and</strong> -4 % -3 both evaluate to -1.<br />

Oper<strong>and</strong>s<br />

expression1 : Number - A number or expression that evaluates to a number.<br />

expression2 : Number - A number or expression that evaluates to a number.<br />

Returns<br />

Number - The result of the arithmetic operation.<br />

Example<br />

The following numeric example uses the modulo (%) operator:<br />

trace(12%5); // traces 2<br />

trace(4.3%2.1); // traces 0.0999999999999996<br />

trace(4%4); // traces 0<br />

The first trace returns 2, rather than 12/5 or 2.4, because the modulo (% ) operator returns<br />

only the remainder. The second trace returns 0.0999999999999996 instead of the expected<br />

0.1 because of the limitations of floating-point accuracy in binary computing.<br />

See also<br />

/ division operator, round (Math.round method)<br />

%= modulo assignment operator<br />

expression1 %= expression2<br />

Assigns expression1 the value of expression1 % expression2. The following two<br />

statements are equivalent:<br />

x %= y; <strong>and</strong> x = x % y;<br />

152 ActionScript language elements

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!