Functional Weave
Code in Rust

Tagged math

16 capabilities

math.clamp
Clamp an integer to an inclusive range, refusing a range whose bounds are the wrong way round.
clamp in Rust
math.rational
Exact fraction arithmetic, always reduced, for rates and ratios that must not drift.
A group of 8: calculate_rational, rational, add_rational, subtract_rational, multiply_rational, divide_rational, compare_rational, rational_to_integer
math.gcd-lcm
Greatest common divisor and least common multiple of two integers, exactly and without overflow.
A group of 3: gcd_lcm, gcd, lcm
math.sin-cos
Sine and cosine of an angle in radians from + - * / only, so every language returns the same doubles.
sin_cos in Rust
math.exp
e to the power x from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
exp in Rust
math.ln
Natural logarithm from + - * / only, so TypeScript, Python and Rust return the same double for the same input.
ln in Rust
math.basis-points
Convert a rate between percent, basis points and a plain ratio exactly, as decimal text or integer basis points.
A group of 3: convert_rate, to_basis_points, from_basis_points
math.atan
Arctangent in radians from + - * / only (fdlibm's method), so every language returns the same double.
atan in Rust
math.pow
base to the power exponent from + - * / only, exact by squaring for whole exponents, identical in every language.
pow in Rust
math.round-float
Round a float half away from zero to 0-12 decimal places, identically in TypeScript, Python and Rust.
round_float in Rust
math.round-div-big
Divide two integers of any size with an explicit rounding mode, on decimal strings, for exact money sums past 2^53.
round_div_big in Rust