Game Development Reference
In-Depth Information
table 1.2 Common math operators used in all programming languages
Operator
Arithmetic
performed
Example in
JavaScript
Value of x
from example
=
Assignment
2
x = 2;
+
Addition
8
y = 5;
x = y + 3;
-
Subtraction
10
y = 15;
z = 5;
x = z - y;
*
Multiplication
45
y = 15;
x = x * 3;
/
Division
3
y = 15;
z = 5;
x = y/z;
Relational Operators
Unlike arithmetic operators that can calculate a plethora of values, relational
operators make comparisons that result in Boolean values (TRUE or FALSE).
The most common operators are given in Table 1.3 .
table 1.3 Common relational operators used in all programming languages
Operator
Arithmetic
performed
Example in
JavaScript
Value of x
from example
>
Greater than
TRUE
y = 5;
z = 2;
x = y > z;
Less than
FALSE
<
y = 10;
z = 3;
x = y < z;
> =
Greater than or
equal to
TRUE
y = 4;
z = 4;
x = z > = y;
Less than or
equal to
TRUE
< =
y = 3;
z = 1;
x = z < = y;
==
Equal to
FALSE
y = 12;
z = 16;
x = y == z
!=
Not equal to
TRUE
y = 12;
z = 16;
x = y != z
Search Nedrilad ::




Custom Search