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.

var x:Number = 65535 >> 8;<br />

trace(x); // outputs 255<br />

The following example shows the result of the previous example:<br />

var x:Number = 255;<br />

This is because 65535 decimal equals 1111111111111111 binary (sixteen 1s),<br />

1111111111111111 binary shifted right by 8 bits is 11111111 binary, <strong>and</strong> 11111111 binary<br />

is 255 decimal. The most significant bit is 0 because the integers are 32-bit, so the fill bit is 0.<br />

The following example converts -1 to a 32-bit integer <strong>and</strong> shifts it 1 bit to the right:<br />

var x:Number = -1 >> 1;<br />

trace(x); // outputs -1<br />

The following example shows the result of the previous example:<br />

var x:Number = -1;<br />

This is because -1 decimal equals 11111111111111111111111111111111 binary (thirtytwo<br />

1s), shifting right by one bit causes the least significant (bit farthest to the right) to be<br />

discarded <strong>and</strong> the most significant bit to be filled in with 1. The result is<br />

11111111111111111111111111111111 (thirty-two 1s) binary, which represents the 32-bit<br />

integer -1.<br />

See also<br />

>>= bitwise right shift <strong>and</strong> assignment operator<br />

>>= bitwise right shift <strong>and</strong> assignment operator<br />

expression1 >>= expression2<br />

This operator performs a bitwise right-shift operation <strong>and</strong> stores the contents as a result in<br />

expression1.<br />

The following two statements are equivalent:<br />

A >>= B; <strong>and</strong> A = (A >> B);<br />

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

expression1 : Number - A number or expression to be shifted right.<br />

expression2 : Number - A number or expression that converts to an integer from 0 to 31.<br />

Returns<br />

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

124 ActionScript language elements

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

Saved successfully!

Ooh no, something went wrong!