this repo has no description
1/**
2 * Given an integer m > 1, called a modulus, two integers are said to be congruent modulo m,
3 * if m is a divisor of their difference (i.e., if there is an integer k such that a \u2212 b = km).
4 *
5 * Unlike JavaScript's remainder operator (%), this mod function never returns negative values.
6 *
7 * @param n An integer
8 * @param m The modulous
9 */
10export function mod(n, m) {
11 return ((n % m) + m) % m;
12}
13/**
14 * Reduce sig fig of `value` to `significantDigits`.
15 * @param value Value to reduce precision of.
16 * @param significantDigits Significant digits to keep.
17 */
18export function reduceSignificantDigits(value, significantDigits) {
19 const roundFactor = Math.pow(10.0, significantDigits);
20 const roundingFunction = value > 0.0 ? Math.floor : Math.ceil;
21 return roundingFunction(value / roundFactor) * roundFactor;
22}
23/**
24 * Clamps a value between an upper and lower bound.
25 * @param value The preferred value.
26 * @param min The minimum allowed value.
27 * @param max The maximum allowed value.
28 */
29export function clamp(value, min, max) {
30 return Math.max(min, Math.min(max, value));
31}
32//# sourceMappingURL=math-util.js.map