» Language: Arithmetic

Sentinel supports arithmetic operators for integers and floats. Sentinel supports sum, difference, product, quotient, and remainder. These all apply to both integers and floats with the exception of remainder which only applies to integers.

+    sum                    integers, floats
-    difference             integers, floats
*    product                integers, floats
/    quotient               integers, floats
%    remainder              integers

These operators work in a typical infix style:

4 + 8 // 12
8 * 2 // 16
8 / 4 // 2
8 / 5 // 1
8 % 5 // 3

» Order of Operations

Arithmetic follows a standard mathematical order of operations. Grouping with parentheses can be used to affect ordering.

4 * 5 / 5 // 4
4 * 5 + 2 // 22
4 + 5 * 2 // 14
(4 + 5) * 2 // 18

A full table of operator precendence can be found on the boolean expressions page. This shows how arithmetic operators relate to other operators.

» Integer Division

Integer division with a remainder rounds down to the nearest integer. Example: 8 / 3 is 2. To receive a float value, convert one of the operands first to a float: float(8) / 3 is 2.666....

If the divisor is zero, an error occurs.