Language: Arithmetic
Sentinel supports arithmetic operators for integers and floats. Sentinel supports sum, difference, product, quotient, and remainder.
+ sum- difference* product/ quotient% remainder
These operators work in a typical infix style:
4 + 8 // 128 * 2 // 168 / 4 // 28 / 5 // 18 % 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 // 44 * 5 + 2 // 224 + 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
.
If the divisor is zero, an error occurs.
Mixed Numeric Operations
Mixed numeric operations between integer and floating-point values are permitted. The result is a floating-point operation with the integer converted to a floating-point value for purposes of calculation.
import "types" a = 1.1 + 1 // 2.1types.type_of(a) // "float"