std/math
Functions
sqrt
pub pure noalloc fn sqrt(x: Float) -> Float
Square root of x; NaN for negative x.
floor
pub pure noalloc fn floor(x: Float) -> Float
Largest integral value not greater than x.
ceil
pub pure noalloc fn ceil(x: Float) -> Float
Smallest integral value not less than x.
round
pub pure noalloc fn round(x: Float) -> Float
x rounded to the nearest integral value, halfway cases away from zero.
pow
pub pure noalloc fn pow(x: Float, y: Float) -> Float
x raised to the power y.
toInt
pub pure noalloc fn toInt(x: Float) -> Int?
x truncated toward zero; None for NaN, an infinity or a value outside the Int range.
toFloat
pub pure noalloc fn toFloat(x: Int) -> Float
x as a Float (rounded above 2^53).
min
pub pure noalloc fn min(a: Int, b: Int) -> Int
The smaller of a and b.
max
pub pure noalloc fn max(a: Int, b: Int) -> Int
The larger of a and b.
min
pub pure noalloc fn min(a: Float, b: Float) -> Float
The smaller of a and b; NaN when either is NaN, and -0.0 when the two are zeros of opposite sign.
max
pub pure noalloc fn max(a: Float, b: Float) -> Float
The larger of a and b; NaN when either is NaN, and 0.0 when the two are zeros of opposite sign.
clamp
pub pure noalloc fn clamp(x: Int, lo: Int, hi: Int) -> Int
x restricted to lo..hi; returns lo if lo > hi.
clamp
pub pure noalloc fn clamp(x: Float, lo: Float, hi: Float) -> Float
x restricted to lo..hi; returns lo if lo > hi, and NaN when any argument is NaN.
abs
pub pure noalloc fn abs(x: Int) -> Int
Absolute value of x; panics with integer overflow at the minimum representable value.
abs
pub pure noalloc fn abs(x: Float) -> Float
Absolute value of x.
min
pub pure noalloc fn min(a: i8, b: i8) -> i8
The smaller of a and b.
max
pub pure noalloc fn max(a: i8, b: i8) -> i8
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: i8, lo: i8, hi: i8) -> i8
x restricted to lo..hi; returns lo if lo > hi.
abs
pub pure noalloc fn abs(x: i8) -> i8
Absolute value of x; panics with integer overflow at the minimum representable value.
min
pub pure noalloc fn min(a: i16, b: i16) -> i16
The smaller of a and b.
max
pub pure noalloc fn max(a: i16, b: i16) -> i16
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: i16, lo: i16, hi: i16) -> i16
x restricted to lo..hi; returns lo if lo > hi.
abs
pub pure noalloc fn abs(x: i16) -> i16
Absolute value of x; panics with integer overflow at the minimum representable value.
min
pub pure noalloc fn min(a: i32, b: i32) -> i32
The smaller of a and b.
max
pub pure noalloc fn max(a: i32, b: i32) -> i32
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: i32, lo: i32, hi: i32) -> i32
x restricted to lo..hi; returns lo if lo > hi.
abs
pub pure noalloc fn abs(x: i32) -> i32
Absolute value of x; panics with integer overflow at the minimum representable value.
min
pub pure noalloc fn min(a: isize, b: isize) -> isize
The smaller of a and b.
max
pub pure noalloc fn max(a: isize, b: isize) -> isize
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: isize, lo: isize, hi: isize) -> isize
x restricted to lo..hi; returns lo if lo > hi.
abs
pub pure noalloc fn abs(x: isize) -> isize
Absolute value of x; panics with integer overflow at the minimum representable value.
min
pub pure noalloc fn min(a: u8, b: u8) -> u8
The smaller of a and b.
max
pub pure noalloc fn max(a: u8, b: u8) -> u8
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: u8, lo: u8, hi: u8) -> u8
x restricted to lo..hi; returns lo if lo > hi.
min
pub pure noalloc fn min(a: u16, b: u16) -> u16
The smaller of a and b.
max
pub pure noalloc fn max(a: u16, b: u16) -> u16
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: u16, lo: u16, hi: u16) -> u16
x restricted to lo..hi; returns lo if lo > hi.
min
pub pure noalloc fn min(a: u32, b: u32) -> u32
The smaller of a and b.
max
pub pure noalloc fn max(a: u32, b: u32) -> u32
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: u32, lo: u32, hi: u32) -> u32
x restricted to lo..hi; returns lo if lo > hi.
min
pub pure noalloc fn min(a: u64, b: u64) -> u64
The smaller of a and b.
max
pub pure noalloc fn max(a: u64, b: u64) -> u64
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: u64, lo: u64, hi: u64) -> u64
x restricted to lo..hi; returns lo if lo > hi.
min
pub pure noalloc fn min(a: usize, b: usize) -> usize
The smaller of a and b.
max
pub pure noalloc fn max(a: usize, b: usize) -> usize
The larger of a and b.
clamp
pub pure noalloc fn clamp(x: usize, lo: usize, hi: usize) -> usize
x restricted to lo..hi; returns lo if lo > hi.