UNPKG

@hastom/fixed-point

Version:

Light lib for fixed point math made around native bigint

17 lines (16 loc) 553 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.abs = exports.max = exports.min = exports.toPrecision = void 0; const toPrecision = (base, to, from) => { if (to === from) { return base; } return base * (10n ** to) / (10n ** from); }; exports.toPrecision = toPrecision; const min = (...args) => args.reduce((m, e) => e < m ? e : m); exports.min = min; const max = (...args) => args.reduce((m, e) => e > m ? e : m); exports.max = max; const abs = (arg) => arg < 0n ? -arg : arg; exports.abs = abs;