This is an old revision of the document!
Arithmetic operators are simply the operations of simple math with integer and floating point numbers.
Arithmetic Operators | |||
---|---|---|---|
Operator | Name | Example | Comments |
+ | Addition | a + b | add two numeric values. If both are an integer, then the result will be an integer. If one or both are floating point numbers then the result will be floating point. If one or both values are strings the plus operator will concatenate the strings.2 |
- | Subtraction | a - b | subtract two numeric values |
* | Multiplication | a * b | |
/ | Division | a / b | Returns a decimal number of times that b goes into a. |
\ | Integer Division | a \ b | Returns the number of whole times that b goes into a. |
% | Modulo | a % b | Returns the remainder of the integer division of a and b. |
++ | Increment Prefix | ++a | Increment (add one) the the variable and return the value after the increment. (may be applied ONLY to numeric variables or array elements) 1 |
++ | Increment Suffix | a++ | Return the value of the variable and then increment the variable by one for the next time it is accessed. (may be applied ONLY to numeric variables or array elements) 1 |
– | Decrement Prefix | –a | Decrement (subtract one) the the variable and return the value after the decrement. (may be applied ONLY to numeric variables or array elements) 1 |
– | Decrrement Suffix | a– | Return the value of the variable and then decrement the variable by one for the next time it is accessed. (may be applied ONLY to numeric variables or array elements) 1 |