OxL Reference

method u32.wrap

x.wrap<U>(): converts to the numeric type U; an integer that does not fit wraps around (keeps the low bits), a float is truncated toward zero (§3.1).

Example:

oxl✓ checked in CI
fn main() io {
  let small: u32 = 200
  let other: u32 = 300
  let x: u8 = small.wrap<u8>()
  let y: u8 = other.wrap<u8>()
  print("{x} {y}")
}
Output
200 44
pub(api) fn wrap<U>() -> U

Complexity. O(1).

Since. 1.0.0-beta

Returns

U

Effects

none declared (pure unless the body says otherwise)

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

See also