[][src]Module fraction::division

Lossless integer division

  • The algorithm uses stack only, no introduced heap allocations for calculation (although underlying integer type implementation may perform those)
  • Linear complexity, O(n)
  • Abstract from a particular integer implementation, may be used on primitive types (as i32 or u32) as well as complex ones (num::BigInt, num::BigUint) Thus can be efficiently used on any integer type implementing a bunch of required traits (which all primitive ints and num::bigint implement out of the box). Although in that case the underlying math will be using heap.

Structs

DivideRemState

State object for divide_rem co-routine

Functions

divide_integral

Divide two numbers and produce every single digit of the whole part of the resulting number

divide_rem

Produces the fractional part of the decimal from a rest part left after division

divide_rem_init_state

Builds the initial state for the divide_rem co-routine.

divide_rem_resume

divide_rem co-routine implementation

divide_to_ascii_vec

Divide a fraction into a Vec<u8> of ASCII(utf8) chars

divide_to_formatter

Divide a fraction into a std::fmt::Formatter

divide_to_string

Divide a fraction into a String