math
Library containing more advanced mathematical operations.
Types
std::math::AccumulateOperation
std::math::AccumulateOperationOptions to use with the std::math::accumulate function.
enum AccumulateOperation : u8 {
Add,
Max,
Min,
Modulo,
Multiply
};Functions
std::math::min
std::math::minCompares the values a and b with each other and returns the smaller of the two
a: First valueb: Second valuereturn:aifais smaller thanb, otherwiseb
fn min(auto a, auto b);std::math::max
std::math::maxCompares the values a and b with each other and returns the bigger of the two
a: First valueb: Second valuereturn:aifais bigger thanb, otherwiseb
fn max(auto a, auto b);std::math::clamp
std::math::clampClamps the value of x between min and max.
x: Valuemin: Minimum valuemax: Maximum valuereturn:minifxis smaller thanmin,maxifxis bigger thanmax,xotherwise
fn clamp(auto x, auto min, auto max);std::math::abs
std::math::absReturns the absolute value of x.
x: Valuereturn:xifxis positive,-xotherwise
fn abs(auto x);std::math::sign
std::math::signReturns the sign of x.
x: Valuereturn:1ifxis positive,-1ifxis negative,0ifxis zero
fn sign(auto x);std::math::copy_sign
std::math::copy_signCopies the sign of y to x.
x: Valuey: Valuereturn:xifyis positive,-xifyis negative
fn copy_sign(auto x, auto y);std::math::factorial
std::math::factorialCalculates the factorial of x.
x: Valuereturn: Factorial ofx
fn factorial(u128 x);std::math::comb
std::math::combCalculates the binomial coefficient of n and k.
n: Valuek: Valuereturn: Binomial coefficient ofnandk
fn comb(u128 n, u128 k);std::math::perm
std::math::permCalculates the permutation of n and k.
n: Valuek: Valuereturn: Permutation ofnandk
fn perm(u128 n, u128 k);std::math::floor
std::math::floorFloors the value of value.
value: Valuereturn:valuefloored
fn floor(auto value);std::math::ceil
std::math::ceilCeils the value of value.
value: Valuereturn:valueceiled
fn ceil(auto value);std::math::round
std::math::roundRounds the value of value.
value: Valuereturn:valuerounded
fn round(auto value);std::math::trunc
std::math::truncTruncates the value of value.
value: Valuereturn:valuetruncated
fn trunc(auto value);std::math::log10
std::math::log10Calculates the logarithm of value with base 10.
value: Valuereturn: Logarithm ofvaluewith base 10
fn log10(auto value);std::math::log2
std::math::log2Calculates the logarithm of value with base 2.
value: Valuereturn: Logarithm ofvaluewith base 2
fn log2(auto value);std::math::ln
std::math::lnCalculates the natural logarithm of value.
value: Valuereturn: Logarithm ofvaluewith basee
fn ln(auto value);std::math::fmod
std::math::fmodCalculates the floating point modulus of value.
value: Valuereturn: Floating point modulus ofvalue
fn fmod(auto value);std::math::pow
std::math::powCalculates the value of base raised to the power of exp.
base: Baseexp: Exponentreturn:baseraised to the power ofexp
fn pow(auto base, auto exp);std::math::exp
std::math::expCalculates the value of the natural number e raised to the power of value.
value: Exponentreturn:eraised to the power ofvalue
fn exp(auto value);std::math::sqrt
std::math::sqrtCalculates the square root of value.
value: Valuereturn: Square root ofvalue
fn sqrt(auto value);std::math::cbrt
std::math::cbrtCalculates the cubic root of value.
value: Valuereturn: Cubic root ofvalue
fn cbrt(auto value);std::math::sin
std::math::sinCalculates the sine of value.
value: Angle value in radiansreturn: Sine ofvalue
fn sin(auto value);std::math::cos
std::math::cosCalculates the cosine of value.
value: Angle value in radiansreturn: Cosine ofvalue
fn cos(auto value);std::math::tan
std::math::tanCalculates the tangent of value.
value: Angle value in radiansreturn: Tangent ofvalue
fn tan(auto value);std::math::asin
std::math::asinCalculates the arc sine of value.
value: Angle value in radiansreturn: Arc sine ofvalue
fn asin(auto value);std::math::acos
std::math::acosCalculates the arc cosine of value.
value: Valuereturn: Arc cosine ofvaluein radians
fn acos(auto value);std::math::atan
std::math::atanCalculates the arc tangent of value.
value: Valuereturn: Arc tangent ofvaluein radians between-pi/2andpi/2
fn atan(auto value);std::math::atan2
std::math::atan2Calculates the arc tangent of value.
y: Value representing the proportion of the y-coordinatex: Value representing the proportion of the x-coordinate.return: Arc tangent ofvaluein radians between-piandpi
fn atan2(auto y, auto x);std::math::sinh
std::math::sinhCalculates the hyperbolic sine of value.
value: Angle value in radiansreturn: Hyperbolic sine ofvalue
fn sinh(auto value);std::math::cosh
std::math::coshCalculates the hyperbolic cosine of value.
value: Angle value in radiansreturn: Hyperbolic cosine ofvalue
fn cosh(auto value);std::math::tanh
std::math::tanhCalculates the hyperbolic tangent of value.
value: Angle value in radiansreturn: Hyperbolic tangent ofvalue
fn tanh(auto value);std::math::asinh
std::math::asinhCalculates the arc hyperbolic sine of value.
value: Valuereturn: Arc hyperbolic sine ofvalue
fn asinh(auto value);std::math::acosh
std::math::acoshCalculates the arc hyperbolic cosine of value.
value: Valuereturn: Arc hyperbolic cosine ofvalue
fn acosh(auto value);std::math::atanh
std::math::atanhCalculates the arc hyperbolic tangent of value.
value: Valuereturn: Arc hyperbolic tangent ofvalue
fn atanh(auto value);std::math::accumulate
std::math::accumulateCalculates the sum of all values in the specified memory range.
start: Start addressend: End addressvalueSize: Size of each value in bytes[section]: Section to use[operation]: Operation to use. Defaults to addition[endian]: Endianness to use. Defaults to nativereturn: Sum of all values in the specified memory range
fn accumulate(u128 start, u128 end, u128 valueSize, std::mem::Section section, std::math::AccumulateOperation operation, std::mem::Endian endian);Last updated
Was this helpful?