Module coil-stdlib

num

Float functions such as sqrt and sin are auto-imported from prelude::math; this module adds the rest. Powers are the ** operator.

Part of coil-stdlib. spool projects get it automatically; with plain coil, pass --root ~/.coil/stdlib/src.

Import what you use (use path::* is not allowed):

use num::{PI, E};

Constants#

NameDescription
PIThe circle constant π, as a float.
EEuler’s number e, the base of ln, as a float.
TAUA full turn τ = 2π, as a float.

Functions#

NameDescription
absReturns the absolute value of x.
minReturns the smaller of a and b (a when they are equal).
maxReturns the larger of a and b (a when they are equal).
roundRounds x to the nearest whole number; halves round away from zero.
clampReturns x limited to the range lo..=hi.
signumReturns -1, 0 or 1 by the sign of x.
gcdReturns the greatest common divisor of a and b, which should be non-negative.
lcmReturns the least common multiple of a and b, which should be non-negative; 0 when either is 0.
truncRemoves the fractional part of x, rounding toward zero.
fractReturns the fractional part of x, x - trunc(x); it has the sign of x.
is_nanReturns true when x is NaN (0.0 / 0.0, sqrt(-1.0), …).
is_infiniteReturns true when x is positive or negative infinity.
is_finiteReturns true when x is neither NaN nor infinite.
rem_euclidReturns the remainder of a / b that is never negative: 0 <= r < abs(b).
div_euclidReturns the quotient that goes with rem_euclid: a == div_euclid(a, b) * b + rem_euclid(a, b).
hypotReturns sqrt(a * a + b * b), the length of the hypotenuse.
↑ ↓ navigate ↵ open