Arithmetic Operators in ActionScript
Notes:
Arithmetic Operators in ActionScript Programming Language:
+: Addition Operator : sum of two numbers
- : Subtraction Operator : difference between two numbers
*: Multiplication Operator : product of two numbers
/: Division Operator : quotient of division operation
%: Modulus Operator : remainder of division operation
Example code:
trace("Arithmetic operators demo");
trace(2+3); // 5
trace(5-3); // 2
trace(5*2); // 10
trace(10/2); //5
trace(10%2); //0
trace(+(-20)); //-20
trace(-(20)); //-20
trace(+(20)); //20
trace(-(-20)); //20
trace("2"+"2"); //22
trace("2"+2);//22
trace(2+"2");//22
trace(4+5.3); //9.3
// parseInt accepts only a string value and returns an integer number
trace(parseInt("2")+parseInt("2"));//4
trace(parseInt("2")+2);//4
trace(1234%10); //4
//Math.floor returns the largest integer less than or equal to a given number.
trace(Math.floor(1234/10)); // 123