@numio/bigmath
Version:
@numio/bigmath is an arbitrary-precision arithmetic library. It can be used for basic operations with decimal numbers (integers and float)
10 lines (9 loc) • 382 B
JavaScript
import { round } from "../round/round.js";
import { bi2s, s2bi } from "../shared/utils.js";
import { cbrtInner } from "./utils.js";
/** Find cube root of a number */
export const cbrt = (value, precision) => {
const valueInner = s2bi(value);
const [bi, decimals] = cbrtInner(valueInner, precision ? s2bi(precision) : undefined);
return round(bi2s(bi), { decimals });
};