Module math

Module math 

Source
Expand description

Math and numeric helpers. Pan math and numeric helpers.

Structs§

PanRng
A small deterministic RNG (not cryptographically secure).

Functions§

abs
Returns the absolute value of number.
add
Adds two numbers. This will not match proper Pan math, which uses either ints/fixed point (I think both of those might wrap on overflow?) or floats (which I think are 32-bit).
arccos
Returns $\arccos(number)$ for inputs in $[-1, 1]$.
arccosh
Returns $\operatorname{arccosh}(number)$ for inputs $\ge 1$.
arcsin
Returns $\arcsin(number)$ for inputs in $[-1, 1]$.
arcsinh
Returns $\operatorname{arcsinh}(number)$.
arctan
Returns $\arctan(number)$.
arctanh
Returns $\operatorname{arctanh}(number)$ for inputs in $(-1, 1)$.
cos
Returns $\cos(number)$.
cosh
Returns $\cosh(number)$.
div
Divides numerator by denominator.
divzero
Divides, returning 0 when denominator is zero.
exp
Returns $e^{number}$.
fact
Returns the factorial of number as an $f64$.
fact_exact
Returns the factorial of n as an exact big integer.
fix
Truncates number toward zero.
fixed
In theory, convert to fixed point. At the moment this returns number unchanged.
float
In theory, converts to floating point. At the moment this returns number unchanged.
fv
Computes the future value for a payment stream.
int
Floors number to the nearest integer toward $-\infty$.
log
Returns the natural logarithm of number.
log10
Returns the base-10 logarithm of number.
max
Returns the larger of a and b.
min
Returns the smaller of a and b.
mul
Multiplies two numbers.
numsandwich
Adds extra unless value is zero.
pmt
Computes the payment for a loan or annuity.
pv
Computes the present value for a payment stream.
round
Rounds number to the nearest multiple of step.
sin
Returns $\sin(number)$.
sinh
Returns $\sinh(number)$.
sqr
Returns $\sqrt{number}$ for non-negative inputs.
sub
Subtracts denominator from numerator.
tan
Returns $\tan(number)$.
tanh
Returns $\tanh(number)$.
zeroblank
Returns None when number is zero, otherwise Some(number).