OxL Reference

method i8.abs

The absolute value. Panics for MIN, whose absolute value does not fit (like unary -).

Example:

oxl✓ checked in CI
fn main() io {
  let x: i8 = -5
  print("{x.abs()} {(7 as i8).abs()}")
}
Output
5 7
pub(api) fn abs() -> i8

Complexity. O(1).

Since. 1.0.0-beta

Returns

i8

Effects

none declared (pure unless the body says otherwise)

Defined in: std/core/numbers.oxl:1271

See also