math
stdlib::rss::math
Numeric constants, predicates, arithmetic helpers, and transcendental functions.
Import
use stdlib::rss::math;
Functions
| Function | Description |
|---|---|
pi | Returns the constant pi. |
tau | Returns the constant tau. |
e | Returns Euler's number. |
epsilon | Returns the machine epsilon for floating-point comparisons. |
inf | Returns positive infinity. |
neg_inf | Returns negative infinity. |
nan | Returns NaN. |
abs | Returns the absolute value of a number. |
min | Returns the smaller of two numbers. |
max | Returns the larger of two numbers. |
clamp | Clamps a number to an inclusive range. |
signum | Returns the sign of a number. |
sign | Returns -1, 0, or 1 depending on the sign of a number. |
in_range | Returns whether a number lies within an inclusive range. |
is_even | Returns whether a number is even. |
is_odd | Returns whether a number is odd. |
sum | Returns the sum of numeric values. |
floor | Rounds a number down to the nearest integer value. |
ceil | Rounds a number up to the nearest integer value. |
round | Rounds a number to the nearest integer value. |
trunc | Truncates the fractional part of a number. |
fract | Returns the fractional part of a number. |
sqrt | Returns the square root of a number. |
cbrt | Returns the cube root of a number. |
powf | Raises a number to a floating-point power. |
powi | Raises a number to an integer power. |
exp | Returns e raised to the given power. |
exp2 | Returns 2 raised to the given power. |
ln | Returns the natural logarithm of a number. |
ln_1p | Returns the natural logarithm of one plus a number. |
log | Returns the logarithm of a number for the given base. |
log2 | Returns the base-2 logarithm of a number. |
log10 | Returns the base-10 logarithm of a number. |
sin | Returns the sine of an angle in radians. |
cos | Returns the cosine of an angle in radians. |
tan | Returns the tangent of an angle in radians. |
asin | Returns the arcsine of a number. |
acos | Returns the arccosine of a number. |
atan | Returns the arctangent of a number. |
atan2 | Returns the four-quadrant arctangent of two numbers. |
sinh | Returns the hyperbolic sine of a number. |
cosh | Returns the hyperbolic cosine of a number. |
tanh | Returns the hyperbolic tangent of a number. |
hypot | Returns the hypotenuse length for two numbers. |
copysign | Returns the first number with the sign of the second number. |
mul_add | Computes a fused multiply-add operation. |
to_degrees | Converts radians to degrees. |
to_radians | Converts degrees to radians. |
deg | Converts radians to degrees. |
rad | Converts degrees to radians. |
fmod | Returns the remainder of dividing lhs by rhs. |
is_nan | Returns whether a number is NaN. |
is_infinite | Returns whether a number is infinite. |
is_finite | Returns whether a number is finite. |
Function details
pi
pub fn pi() -> float
Returns the constant pi.
tau
pub fn tau() -> float
Returns the constant tau.
e
pub fn e() -> float
Returns Euler's number.
epsilon
pub fn epsilon() -> float
Returns the machine epsilon for floating-point comparisons.
inf
pub fn inf() -> float
Returns positive infinity.
neg_inf
pub fn neg_inf() -> float
Returns negative infinity.
nan
pub fn nan() -> float
Returns NaN.
abs
pub fn abs(value: number) -> number
Returns the absolute value of a number.
min
pub fn min(lhs: number, rhs: number) -> number
Returns the smaller of two numbers.
max
pub fn max(lhs: number, rhs: number) -> number
Returns the larger of two numbers.
clamp
pub fn clamp(value: number, lower: number, upper: number) -> number
Clamps a number to an inclusive range.
signum
pub fn signum(value: number) -> number
Returns the sign of a number.
sign
pub fn sign(value: number) -> int
Returns -1, 0, or 1 depending on the sign of a number.
in_range
pub fn in_range(value: number, lower: number, upper: number) -> bool
Returns whether a number lies within an inclusive range.
is_even
pub fn is_even(value: int) -> bool
Returns whether a number is even.
is_odd
pub fn is_odd(value: int) -> bool
Returns whether a number is odd.
sum
pub fn sum(values: [number]) -> number
Returns the sum of numeric values.
floor
pub fn floor(value: number) -> number
Rounds a number down to the nearest integer value.
ceil
pub fn ceil(value: number) -> number
Rounds a number up to the nearest integer value.
round
pub fn round(value: number) -> number
Rounds a number to the nearest integer value.
trunc
pub fn trunc(value: number) -> number
Truncates the fractional part of a number.
fract
pub fn fract(value: number) -> float
Returns the fractional part of a number.
sqrt
pub fn sqrt(value: number) -> float
Returns the square root of a number.
cbrt
pub fn cbrt(value: number) -> float
Returns the cube root of a number.
powf
pub fn powf(value: number, exponent: number) -> float
Raises a number to a floating-point power.
powi
pub fn powi(value: number, exponent: int) -> float
Raises a number to an integer power.
exp
pub fn exp(value: number) -> float
Returns e raised to the given power.
exp2
pub fn exp2(value: number) -> float
Returns 2 raised to the given power.
ln
pub fn ln(value: number) -> float
Returns the natural logarithm of a number.
ln_1p
pub fn ln_1p(value: number) -> float
Returns the natural logarithm of one plus a number.
log
pub fn log(value: number, base: number) -> float
Returns the logarithm of a number for the given base.
log2
pub fn log2(value: number) -> float
Returns the base-2 logarithm of a number.
log10
pub fn log10(value: number) -> float
Returns the base-10 logarithm of a number.
sin
pub fn sin(value: number) -> float
Returns the sine of an angle in radians.
cos
pub fn cos(value: number) -> float
Returns the cosine of an angle in radians.
tan
pub fn tan(value: number) -> float
Returns the tangent of an angle in radians.
asin
pub fn asin(value: number) -> float
Returns the arcsine of a number.
acos
pub fn acos(value: number) -> float
Returns the arccosine of a number.
atan
pub fn atan(value: number) -> float
Returns the arctangent of a number.
atan2
pub fn atan2(y: number, x: number) -> float
Returns the four-quadrant arctangent of two numbers.
sinh
pub fn sinh(value: number) -> float
Returns the hyperbolic sine of a number.
cosh
pub fn cosh(value: number) -> float
Returns the hyperbolic cosine of a number.
tanh
pub fn tanh(value: number) -> float
Returns the hyperbolic tangent of a number.
hypot
pub fn hypot(lhs: number, rhs: number) -> float
Returns the hypotenuse length for two numbers.
copysign
pub fn copysign(value: number, sign_value: number) -> float
Returns the first number with the sign of the second number.
mul_add
pub fn mul_add(a: number, b: number, c: number) -> float
Computes a fused multiply-add operation.
to_degrees
pub fn to_degrees(value: number) -> float
Converts radians to degrees.
to_radians
pub fn to_radians(value: number) -> float
Converts degrees to radians.
deg
pub fn deg(value: number) -> float
Converts radians to degrees.
rad
pub fn rad(value: number) -> float
Converts degrees to radians.
fmod
pub fn fmod(lhs: number, rhs: number) -> number
Returns the remainder of dividing lhs by rhs.
is_nan
pub fn is_nan(value: number) -> bool
Returns whether a number is NaN.
is_infinite
pub fn is_infinite(value: number) -> bool
Returns whether a number is infinite.
is_finite
pub fn is_finite(value: number) -> bool
Returns whether a number is finite.