Expand description
Division and modulus traits and implementations.
There are several definitions for the division and modulus
functions, each with different properties.
Probably the most common in computer science is truncated division
(rounding towards zero) since it is the one provided by most processors
and defined as the /
(and matching %
) operator in the ISO C99 standard.
This crate provides the following definitions:
- Floored division (rounding towards negative infinity).
- Ceiled division (rounding towards positive infinity).
- Euclidean division (sign of modulus is always positive).
For every definition, we provide a Div
, a Rem
and a DivRem
variant.
A DivRem
variant of the truncated division is also provided for
convenience since it does not exist in the standard library.
Traitsยง
- DivCeil
- Ceiled division.
- DivEuclid
- Euclidean division.
- DivFloor
- Floored division.
- DivRem
- Truncated division and remainder.
- DivRem
Ceil - Ceiled division and remainder.
- DivRem
Euclid - Euclidean division and remainder.
- DivRem
Floor - Floored division and remainder.
- RemCeil
- Ceiled division remainder.
- RemEuclid
- Euclidean remainder.
- RemFloor
- Floored division remainder.