Trait SaturatingAbsAssign

Source
pub trait SaturatingAbsAssign {
    // Required method
    fn saturating_abs_assign(&mut self);
}
Expand description

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

Required Methods§

Implementations on Foreign Types§

Source§

impl SaturatingAbsAssign for i8

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl SaturatingAbsAssign for i16

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl SaturatingAbsAssign for i32

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl SaturatingAbsAssign for i64

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl SaturatingAbsAssign for i128

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Source§

impl SaturatingAbsAssign for isize

Source§

fn saturating_abs_assign(&mut self)

Replaces a number with its absolute value, saturating at the numeric bounds instead of overflowing.

$$ x \gets \begin{cases} |x| & \text{if} \quad x > -2^{W-1}, \\ 2^{W-1} - 1 & \text{if} \quad x = -2^{W-1}, \end{cases} $$ where $W$ is Self::WIDTH.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

Implementors§