DRAFTThis page is not published. Only visible in development mode.
Functions
Arithmetic Overflow & none Policies
Every arithmetic function family (math::add, math::sub, math::mul, math::div, math::rem) has explicit variants that decide what happens on overflow or missing input.
The policies
| Variant | Behavior |
|---|---|
| math::add::none | Returns none on missing input or overflow. |
| math::add::saturate | Clamps to the type's minimum or maximum on overflow. |
| math::add::wrap | Wraps around on overflow (two's complement). |
| math::add::zero | Returns zero on missing input or overflow. |
| math::add::default | Returns the type's default value. |
| math::add::strict | Fails the statement on missing input or overflow. |
Why explicit policies
Silent overflow and silently propagated missing values are the two classic numeric bugs. Naming the policy in the function makes the behavior visible in the query. This page will document each family with runnable examples per policy.
