Arithmetic Operators in Actionscript : Arithmetic Operators « Language « Flash / Flex / ActionScript






Arithmetic Operators in Actionscript

 

Operator     Name                Example     
+            Plus                x + y       
-            Minus/Negation      x - y       
*            Multiply            x*y       
/            Divide              x/y       
%            Modulo              x%y       

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var nYear:Number = 2004;
        trace(nYear % 4); // Displays: 0
        
    }
  }
}

        








Related examples in the same category

1.Assignment Operators
2.myVariable += 6; is the shorthand version of the following: myVariable = myVariable + 6;
3.myVariable *= 6; is the same as: myVariable = myVariable * 6;
4.Using Mathematical Operators: prefix and postfix
5.Modulo (%)
6.Increment (++) and Decrement ( -- )
7.Compound Assignment Operators (+=, -=, *=, /=, and %=): x += 1; is the same as writing x = x + 1;