An arithmetic operator you may not be familiar with is the remainder operator, or the modulus operator. The remainder operator
% returns the remainder from the division of numbers, even if they are decimals. For example, "5 % 2" will return 1 as the remainder of five divided by two is one. Other special operators include the increment and decrement operator, which increments/decrements a variable's value by one.
The sample code above show a variety of variables as well as arithmetic operators and how they function. Incrementing and decrementing a variable (
b++) is actually the same as doing
b = b + 1, but with less effort. As explained above, dividing any number by zero will result in positive or negative infinity based on the sign of the first operand. Zero divided by zero will return NaN, which stands for "Not a number". Using the remainder operator with a negative number and a positive number will result in the a negative value for the remainder, as shown with