rounding
Rounding & Precision Utilities
Various rounding modes and precision control for DeFi applications.
Rounding Modes
round_down/round_up- Floor/Ceilinground_half_up- Standard rounding (0.5 rounds up)round_toward_zero- Truncationround_away_from_zero- Round away from zero
Precision Control
truncate_decimals- Truncate to N decimal placesround_to_decimals- Round to N decimal places
Comparison & Clamping
approx_equal- Check equality within toleranceclamp- Constrain value to rangemin/max- Minimum/Maximum
Fully qualified path: cairo_fp::f128::math::rounding
Free functions
| round_down | Rounds down to the nearest integer (floor). |
| round_up | Rounds up to the nearest integer (ceiling). |
| round_half_up | Standard rounding (half up). Rounds to nearest integer, with 0.5 rounding up. |
| round_toward_zero | Rounds toward zero (truncation)…. |
| round_away_from_zero | Rounds away from zero…. |
| truncate_decimals | — |
| round_to_decimals | — |
| approx_equal | — |
| clamp | — |
| min | — |
| max | — |
| _split_unsigned | — |