Math Operators | ||
---|---|---|
Sign | Read as | Purpose |
+ | "plus" | Addition. |
- | "minus" | Subtraction. |
* | "times" | Multiplication. |
/ | "divided by" | Real division. |
% | "modulo" | Modulus is used to obtain the remainder of an integer division. |
Unary Operators | ||
---|---|---|
Sign | Read as | Purpose |
- | "negative" | Makes a number negative. |
Relational Operators | ||
---|---|---|
Sign | Read as | Purpose |
== | "is equal to" | Tests two values for equality. |
!= | "is not equal to" | Tests two values for inequality. Notes. |
>= | "is greater than or equal to" | Tests to see if the left value is greater than or equal to the right value. |
<= | "is less than or equal to" | Tests to see if the left value is less than or equal to the right value. |
> | "is greater than" | Tests to see if the left value is greater than the right value. |
< | "is less than" | Tests to see if the left value is less than the right value. |
Logical Operators | ||
---|---|---|
Sign | Read as | Purpose |
! | "not" | Reverses a boolean value. |
&& | "and" | This operator returns a true value if both of the boolean values on each side of the operator are true. |
|| | "or" | This operator returns a true value if either of the boolean values on each side of the operator is true. |
Bitwise Operators | ||
---|---|---|
Sign | Name | Purpose |
& | Bitwise And | Tests the bits of two numbers and returns a number with only the bits that both numbers had. |
| | Bitwise Or | Tests the bits of two numbers and returns a number with the bits that either number had. |
^ | Exclusive Or (XOR) | Tests the bits of two numbers and returns a number with the bits that only one number had. |
Assignment Operators | ||
---|---|---|
Sign | Read as | Purpose |
= | "is assigned to" | Assigns the variable on the left to the value on the right. |
Operator Precedence and Associativity | ||
---|---|---|
Precedence | Associativity | Category |
( ) [ ] | left to right | Function Call, Parentheses, Array Index |
- | right to left | Unary Negation |
* / % | left to right | Multiplication |
+ - | left to right | Addition |
>= <= < > | left to right | Relational Operators |
== != | left to right | Equality Operators |
! | right to left | Logical "not" |
& | left to right | Bitwise "and" |
^ | left to right | Exclusive "or" (XOR) |
| | left to right | Bitwise "or" |
&& | left to right | Logical "and" |
|| | left to right | Logical "or" |
= | right to left | Assignment |
, | left to right | Comma |
Information on Precedence. | ||
Information on Associativity. |