Arithmetic expressions in Gosu
Gosu defines arithmetic expressions corresponding to all the common arithmetic operators, which are:
- Addition and Concatenation Operator (+)
- Subtraction Operator (-)
- Multiplication Operator (*)
- Division Operator (/)
- Arithmetic Modulo Operator (%)
Using big decimal arithmetic in Gosu
Gosu supports Java big decimal arithmetic on the +,
-, *, /, and %
arithmetic operators. If the left-hand or right-hand operand of the operator is a Java
BigDecimal or BigInteger, the result is
BigDecimal or BigInteger also. This coercion is
especially important for accuracy, which currency values often require.
Overflow errors
By default, Gosu arithmetic expressions do not check for overflow errors. Optionally you can enable checked arithmetic, which generates Gosu exceptions for overflow errors.
See also
