::std::ops::

Function abs_trunc

pub fn abs_trunc<#uint N>(x: int<N>) -> int<N>
Expand

Computes the absolute value of a signed integer, truncated to fit the output type bounds.

Such truncation means that the most negative value (whose absolute value cannot be represented using the same number of bits) is mapped to itself.

Examples

assert abs_trunc(0i8) == 0i8;
assert abs_trunc(15i8) == 15i8;
assert abs_trunc(-7i8) == 7i8;