pub trait ArithmeticCheckedShr<RHS> {
    type Output;

    fn arithmetic_checked_shr(self, other: RHS) -> Option<Self::Output>;
}
Expand description

Right-shifts a number (divides it by a power of 2), returning None if the result is not representable.

Required Associated Types

Required Methods

Implementations on Foreign Types

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0).

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x < 2^W, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ 2^{-b} x \geq 2^W, \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Shifts a number right (divides it by a power of 2). If the result is too large to be represented, None is returned.

Zero may be shifted by any amount, and any number may be shifted by any non- negative amount; shifting by a large amount returns Some(0) if self is positive, and Some(-1) if self is negative.

$$ f(x, b) = \begin{cases} \operatorname{Some}(\lfloor x/2^b \rfloor) & \text{if} \quad b \geq 0, \\ \operatorname{Some}(2^{-b} x) & \text{if} \quad b < 0 \ \mathrm{and} \ -2^{W-1} \leq 2^{-b} x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad b < 0 \ \mathrm{and} \ (2^{-b} x < -2^{W-1} \ \mathrm{or} \ 2^{-b} x \geq 2^{W-1}), \\ \end{cases} $$ where $W$ is Self::WIDTH.

Worst-case complexity

Constant time and additional memory.

Examples

See here.

Implementors