std::math
This module contains mathematical functions.
Functions
-
abs(x: i64|f64) -> i64|f64 -
Returns the absolute value of
x. The output type is the same as the input type.Panics if the argument is an
i64with valuei64_min(i.e. the most negativei64integer) as the result cannot be represented as ani64value. -
acos(x: i64|f64) -> f64 -
Returns the arc cosine of
xin radians. -
asin(x: i64|f64) -> f64 -
Returns the arc sine of
xin radians. -
atan(x: i64|f64) -> f64 -
Returns the arc tangent of
xin radians. -
atan2(y: i64|f64, x: i64|f64) -> f64 -
Returns the arc tangent of
y/xin radians as anf64using the signs of the arguments to determine the correct quadrant. -
cbrt(x: i64|f64) -> f64 -
Returns the cubic root of
x. -
ceil(x: i64|f64) -> f64 -
Returns the lowest integer value greater than or equal to
xas a float. -
cos(x: i64|f64) -> f64 -
Returns the cosine of
x, wherexis in radians. -
exp(x: i64|f64) -> f64 -
Returns
eto the power ofx. -
floor(x: i64|f64) -> f64 -
Returns the highest integer value less than or equal to
xas a float. -
floor_div(numerator: i64, denominator: i64) -> (i64, i64) -
Computes the quotient and remainder of the floored-integer division
numerator/denominator. In floored-integer division, the quotient is rounded toward negative infinity.Returns the result as a two-item
(quotient, remainder)tuple. The result satisfies the condition:assert quotient * denominator + remainder == numerator;
Panics if the
denominatoris zero.This function returns the same remainder as the
modoperator. -
ln(x: i64|f64) -> f64 -
Returns the natural logarithm (i.e. the base-e logarithm) of
x. -
log(b: i64|f64, x: i64|f64) -> f64 -
Returns the base
blogarithm ofx. -
log2(x: i64|f64) -> f64 -
Returns the base-2 logarithm of
x. -
log10(x: i64|f64) -> f64 -
Returns the base-10 logarithm of
x. -
modulo(x: i64, y: i64) -> i64 -
Returns the result of the integer operation
x modulo y.Panics if
yis zero. -
sin(x: i64|f64) -> f64 -
Returns the sine of
x, wherexis in radians. -
sqrt(x: i64|f64) -> f64 -
Returns the square root of
x. -
tan(x: i64|f64) -> f64 -
Returns the tangent of
x, wherexis in radians. -
trunc_div(numerator: i64, denominator: i64) -> (i64, i64) -
Computes the quotient and remainder of the truncated-integer division
numerator/denominator. In truncated-integer division, the quotient is rounded toward zero.Returns the result as a two-item
(quotient, remainder)tuple. The result satisfies the condition:assert quotient * denominator + remainder == numerator;
Panics if the
denominatoris zero.This function returns the same quotient as the
//operator and the same remainder as theremoperator.