pub trait ArithmeticCheckedShl<RHS> {
    type Output;

    // Required method
    fn arithmetic_checked_shl(self, other: RHS) -> Option<Self::Output>;
}
Expand description

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

Required Associated Types§

Required Methods§

source

fn arithmetic_checked_shl(self, other: RHS) -> Option<Self::Output>

Implementations on Foreign Types§

source§

impl ArithmeticCheckedShl<i8> for i8

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<i8> for i16

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<i8> for i32

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<i8> for i64

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<i8> for i128

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<i8> for isize

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<i8> for u8

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<i8> for u16

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<i8> for u32

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<i8> for u64

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<i8> for u128

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<i8> for usize

source§

fn arithmetic_checked_shl(self, bits: i8) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<i16> for i8

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<i16> for i16

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<i16> for i32

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<i16> for i64

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<i16> for i128

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<i16> for isize

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<i16> for u8

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<i16> for u16

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<i16> for u32

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<i16> for u64

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<i16> for u128

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<i16> for usize

source§

fn arithmetic_checked_shl(self, bits: i16) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<i32> for i8

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<i32> for i16

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<i32> for i32

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<i32> for i64

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<i32> for i128

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<i32> for isize

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<i32> for u8

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<i32> for u16

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<i32> for u32

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<i32> for u64

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<i32> for u128

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<i32> for usize

source§

fn arithmetic_checked_shl(self, bits: i32) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<i64> for i8

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<i64> for i16

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<i64> for i32

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<i64> for i64

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<i64> for i128

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<i64> for isize

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<i64> for u8

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<i64> for u16

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<i64> for u32

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<i64> for u64

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<i64> for u128

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<i64> for usize

source§

fn arithmetic_checked_shl(self, bits: i64) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<i128> for i8

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<i128> for i16

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<i128> for i32

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<i128> for i64

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<i128> for i128

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<i128> for isize

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<i128> for u8

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<i128> for u16

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<i128> for u32

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<i128> for u64

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<i128> for u128

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<i128> for usize

source§

fn arithmetic_checked_shl(self, bits: i128) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<isize> for i8

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<i8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i8

source§

impl ArithmeticCheckedShl<isize> for i16

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<i16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i16

source§

impl ArithmeticCheckedShl<isize> for i32

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<i32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i32

source§

impl ArithmeticCheckedShl<isize> for i64

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<i64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i64

source§

impl ArithmeticCheckedShl<isize> for i128

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<i128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = i128

source§

impl ArithmeticCheckedShl<isize> for isize

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<isize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0) if self is positive, and Some(-1) if self is negative.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = isize

source§

impl ArithmeticCheckedShl<isize> for u8

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<u8>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<isize> for u16

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<u16>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<isize> for u32

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<u32>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<isize> for u64

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<u64>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<isize> for u128

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<u128>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<isize> for usize

source§

fn arithmetic_checked_shl(self, bits: isize) -> Option<usize>

Left-shifts a number (multiplies 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 negative amount; shifting by a negative amount with a high absolute value returns Some(0).

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<u8> for i8

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<u8> for i16

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<u8> for i32

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<u8> for i64

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<u8> for i128

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<u8> for isize

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<u8> for u8

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<u8> for u16

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<u8> for u32

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<u8> for u64

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<u8> for u128

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<u8> for usize

source§

fn arithmetic_checked_shl(self, bits: u8) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<u16> for i8

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<u16> for i16

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<u16> for i32

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<u16> for i64

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<u16> for i128

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<u16> for isize

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<u16> for u8

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<u16> for u16

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<u16> for u32

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<u16> for u64

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<u16> for u128

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<u16> for usize

source§

fn arithmetic_checked_shl(self, bits: u16) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<u32> for i8

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<u32> for i16

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<u32> for i32

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<u32> for i64

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<u32> for i128

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<u32> for isize

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<u32> for u8

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<u32> for u16

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<u32> for u32

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<u32> for u64

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<u32> for u128

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<u32> for usize

source§

fn arithmetic_checked_shl(self, bits: u32) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<u64> for i8

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<u64> for i16

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<u64> for i32

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<u64> for i64

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<u64> for i128

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<u64> for isize

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<u64> for u8

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<u64> for u16

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<u64> for u32

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<u64> for u64

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<u64> for u128

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<u64> for usize

source§

fn arithmetic_checked_shl(self, bits: u64) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<u128> for i8

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<u128> for i16

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<u128> for i32

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<u128> for i64

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<u128> for i128

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<u128> for isize

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<u128> for u8

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<u128> for u16

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<u128> for u32

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<u128> for u64

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<u128> for u128

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<u128> for usize

source§

fn arithmetic_checked_shl(self, bits: u128) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

source§

impl ArithmeticCheckedShl<usize> for i8

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<i8>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i8

source§

impl ArithmeticCheckedShl<usize> for i16

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<i16>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i16

source§

impl ArithmeticCheckedShl<usize> for i32

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<i32>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i32

source§

impl ArithmeticCheckedShl<usize> for i64

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<i64>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i64

source§

impl ArithmeticCheckedShl<usize> for i128

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<i128>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = i128

source§

impl ArithmeticCheckedShl<usize> for isize

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<isize>

Left-shifts a number (multiplies 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.

$$ f(x, b) = \begin{cases} \operatorname{Some}(2^b x) & \text{if} \quad -2^{W-1} \leq 2^b x < 2^{W-1}, \\ \operatorname{None} & \text{if} \quad 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.

§

type Output = isize

source§

impl ArithmeticCheckedShl<usize> for u8

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<u8>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u8

source§

impl ArithmeticCheckedShl<usize> for u16

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<u16>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u16

source§

impl ArithmeticCheckedShl<usize> for u32

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<u32>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u32

source§

impl ArithmeticCheckedShl<usize> for u64

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<u64>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u64

source§

impl ArithmeticCheckedShl<usize> for u128

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<u128>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = u128

source§

impl ArithmeticCheckedShl<usize> for usize

source§

fn arithmetic_checked_shl(self, bits: usize) -> Option<usize>

Left-shifts a number (multiplies 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.

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

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

§

type Output = usize

Implementors§