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
i64
with valuei64_min
(i.e. the most negativei64
integer) as the result cannot be represented as ani64
value. -
acos(x: i64|f64) -> f64
-
Returns the arc cosine of
x
in radians. -
asin(x: i64|f64) -> f64
-
Returns the arc sine of
x
in radians. -
atan(x: i64|f64) -> f64
-
Returns the arc tangent of
x
in radians. -
atan2(y: i64|f64, x: i64|f64) -> f64
-
Returns the arc tangent of
y/x
in radians as anf64
using 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
x
as a float. -
cos(x: i64|f64) -> f64
-
Returns the cosine of
x
, wherex
is in radians. -
exp(x: i64|f64) -> f64
-
Returns
e
to the power ofx
. -
floor(x: i64|f64) -> f64
-
Returns the highest integer value less than or equal to
x
as 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
denominator
is zero.This function returns the same remainder as the
mod
operator. -
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
b
logarithm 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
y
is zero. -
sin(x: i64|f64) -> f64
-
Returns the sine of
x
, wherex
is in radians. -
sqrt(x: i64|f64) -> f64
-
Returns the square root of
x
. -
tan(x: i64|f64) -> f64
-
Returns the tangent of
x
, wherex
is 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
denominator
is zero.This function returns the same quotient as the
//
operator and the same remainder as therem
operator.