Operations and constants for uint
of iter::Times for uint
div_ceil
- Divide two numbers, return the result, rounded up.div_floor
- Divide two numbers, return the result, rounded down.div_round
- Divide two numbers, return the result, rounded to the closest integer.iterate
- Iterate over the range [lo
..hi
), or stop when requestednext_power_of_two
- Returns the smallest power of 2 greater than or equal to n
iter::Times
for uint
times
fn times(&self, it: &fn() -> bool) -> bool
A convenience form for basic iteration. Given a uint x
, for x.times { ... }
executes the given block x times.
Equivalent to for uint::range(0, x) |_| { ... }
.
Not defined on all integer types to permit unambiguous use with integer literals of inferred integer-type as the self-value (eg. for 100.times { ... }
).
div_ceil
fn div_ceil(x: uint, y: uint) -> uint
Divide two numbers, return the result, rounded up.
The smallest integer q
such that x/y <= q
.
div_floor
fn div_floor(x: uint, y: uint) -> uint
Divide two numbers, return the result, rounded down.
Note: This is the same function as div
.
The smallest integer q
such that x/y <= q
. This is either x/y
or x/y + 1
.
div_round
fn div_round(x: uint, y: uint) -> uint
Divide two numbers, return the result, rounded to the closest integer.
The integer q
closest to x/y
.
iterate
fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool
Iterate over the range [lo
..hi
), or stop when requested
true
to continue, false
to stop.true
If execution proceeded correctly, false
if it was interrupted, that is if it
returned false
at any point.
next_power_of_two
fn next_power_of_two(n: uint) -> uint
Returns the smallest power of 2 greater than or equal to n