#division #modulo #no-std

no-std divrem

Division and modulus variants

2 releases (1 stable)

1.0.0 May 9, 2021
0.1.0 May 30, 2018

#423 in Math

Download history 2756/week @ 2024-06-22 2217/week @ 2024-06-29 2917/week @ 2024-07-06 2940/week @ 2024-07-13 2719/week @ 2024-07-20 3246/week @ 2024-07-27 4394/week @ 2024-08-03 3926/week @ 2024-08-10 3888/week @ 2024-08-17 4376/week @ 2024-08-24 5030/week @ 2024-08-31 4265/week @ 2024-09-07 3753/week @ 2024-09-14 4107/week @ 2024-09-21 4225/week @ 2024-09-28 4307/week @ 2024-10-05

16,829 downloads per month
Used in 33 crates (6 directly)

MIT license

27KB
579 lines

DivRem

Documentation

Rust library providing division and modulus variants:

  • Floored division and remainder.
  • Ceiled division and remainder.
  • Euclidian division and remaider.

For every definition, we provide a Div, a Rem and a DivRem trait.

A DivRem variant of std’s truncated division is also provided for convenience.

This crate is no_std.


lib.rs:

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.

No runtime deps