Type promotion converts operands or results to a numeric type able to represent the required precision or range. In Clojure arithmetic, the result generally follows the most “contagious” operand type: a more precise numeric operand influences the operation’s result. section 5.13
The practical rule is:
- Mixed numeric types affect the type of an arithmetic result. section 5.13
- Greater precision generally propagates through the operation. section 5.13
- Promotion is distinct from overflow behavior: unchecked integer operations can wrap at the limits of their resulting type. section 5.13
Converting a rational result
An explicit conversion makes the resulting representation visible: `(double (- 10 1/3))` produces `9.666666666666668`, rather than retaining the exact rational form.
