Operations and constants for uint

Implementation of iter::Times for uint

Method 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 { ... }).

Function div_ceil

fn div_ceil(x: uint, y: uint) -> uint

Divide two numbers, return the result, rounded up.

Arguments

Return value

The smallest integer q such that x/y <= q.

Function 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.

Arguments

Return value

The smallest integer q such that x/y <= q. This is either x/y or x/y + 1.

Function div_round

fn div_round(x: uint, y: uint) -> uint

Divide two numbers, return the result, rounded to the closest integer.

Arguments

Return value

The integer q closest to x/y.

Function iterate

fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool

Iterate over the range [lo..hi), or stop when requested

Arguments

Return value

true If execution proceeded correctly, false if it was interrupted, that is if it returned false at any point.

Function next_power_of_two

fn next_power_of_two(n: uint) -> uint

Returns the smallest power of 2 greater than or equal to n