math

stdlib::rss::math

Numeric constants, predicates, arithmetic helpers, and transcendental functions.

Import

use stdlib::rss::math;

Functions

FunctionDescription
piReturns the constant pi.
tauReturns the constant tau.
eReturns Euler's number.
epsilonReturns the machine epsilon for floating-point comparisons.
infReturns positive infinity.
neg_infReturns negative infinity.
nanReturns NaN.
absReturns the absolute value of a number.
minReturns the smaller of two numbers.
maxReturns the larger of two numbers.
clampClamps a number to an inclusive range.
signumReturns the sign of a number.
signReturns -1, 0, or 1 depending on the sign of a number.
in_rangeReturns whether a number lies within an inclusive range.
is_evenReturns whether a number is even.
is_oddReturns whether a number is odd.
sumReturns the sum of numeric values.
floorRounds a number down to the nearest integer value.
ceilRounds a number up to the nearest integer value.
roundRounds a number to the nearest integer value.
truncTruncates the fractional part of a number.
fractReturns the fractional part of a number.
sqrtReturns the square root of a number.
cbrtReturns the cube root of a number.
powfRaises a number to a floating-point power.
powiRaises a number to an integer power.
expReturns e raised to the given power.
exp2Returns 2 raised to the given power.
lnReturns the natural logarithm of a number.
ln_1pReturns the natural logarithm of one plus a number.
logReturns the logarithm of a number for the given base.
log2Returns the base-2 logarithm of a number.
log10Returns the base-10 logarithm of a number.
sinReturns the sine of an angle in radians.
cosReturns the cosine of an angle in radians.
tanReturns the tangent of an angle in radians.
asinReturns the arcsine of a number.
acosReturns the arccosine of a number.
atanReturns the arctangent of a number.
atan2Returns the four-quadrant arctangent of two numbers.
sinhReturns the hyperbolic sine of a number.
coshReturns the hyperbolic cosine of a number.
tanhReturns the hyperbolic tangent of a number.
hypotReturns the hypotenuse length for two numbers.
copysignReturns the first number with the sign of the second number.
mul_addComputes a fused multiply-add operation.
to_degreesConverts radians to degrees.
to_radiansConverts degrees to radians.
degConverts radians to degrees.
radConverts degrees to radians.
fmodReturns the remainder of dividing lhs by rhs.
is_nanReturns whether a number is NaN.
is_infiniteReturns whether a number is infinite.
is_finiteReturns 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.