Standard library
std/math
Floating-point math and integer limits.
Constants: Pi, E, MaxInt, MinInt
Functions: sqrt, pow, abs, floor, ceil, round, sin, cos, tan, atan2, log, exp, isNaN, inf
Constants
Pi
pub const Pi = 3.141592653589793π, the ratio of a circle's circumference to its diameter.
E
pub const E = 2.718281828459045e, the base of natural logarithms.
MaxInt, MinInt
pub const MaxInt = 9223372036854775807
pub const MinInt = -9223372036854775808The largest and smallest int.
Functions
sqrt
pub fn sqrt(x: f64) -> f64The square root; NaN for negative numbers.
pow
pub fn pow(x: f64, y: f64) -> f64x to the power y.
abs
pub fn abs(x: f64) -> f64The absolute value.
floor, ceil, round
pub fn floor(x: f64) -> f64
pub fn ceil(x: f64) -> f64
pub fn round(x: f64) -> f64Rounds down, up, and to the nearest integer (halves away from zero).
sin, cos, tan
pub fn sin(x: f64) -> f64
pub fn cos(x: f64) -> f64
pub fn tan(x: f64) -> f64Trigonometric functions, in radians.
atan2
pub fn atan2(y: f64, x: f64) -> f64The angle of the point (x, y) from the x axis, in (-π, π].
log, exp
pub fn log(x: f64) -> f64
pub fn exp(x: f64) -> f64The natural logarithm, and e to the power x.
isNaN
pub fn isNaN(x: f64) -> boolWhether x is not a number (the result of 0.0 / 0.0, sqrt(-1.0)).
inf
pub fn inf() -> f64Positive infinity.