Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
@yaffle/bigdecimal
Advanced tools
Arbitrary precision decimal arithmetic library. Polyfill for decimal proposal. Implemented on the top of BigInt.
a polyfill for decimal propocal - https://github.com/tc39/proposal-decimal It is implemented on the top of native BigInt. It can be compiled using https://www.npmjs.com/package/babel-plugin-transform-bigint to use JSBI.
npm install @yaffle/bigdecimal
BigDecimal.BigDecimal(string)
BigDecimal.BigDecimal(bigint)
BigDecimal.BigDecimal(number) // (only integers)
a.toString()
a.toFixed(fractionDigits[, roundingMode = "half-up"])
a.toPrecision(precision[, roundingMode = "half-up"])
a.toExponential(fractionDigits[, roundingMode = "half-up"])
BigDecimal.unaryMinus(a)
BigDecimal.add(a, b[, rounding])
BigDecimal.subtract(a, b[, rounding])
BigDecimal.multiply(a, b[, rounding])
BigDecimal.divide(a, b, rounding)
BigDecimal.round(a, rounding)
BigDecimal.cmp(a, b)
To use:
import addMath from './BigDecimalMath.js';
addMath(BigDecimal, 10);
BigDecimal.abs(a)
BigDecimal.sign(a)
BigDecimal.max(a, b)
BigDecimal.min(a, b)
BigDecimal.log(a, rounding)
BigDecimal.exp(a, rounding)
BigDecimal.sin(a, rounding)
BigDecimal.cos(a, rounding)
BigDecimal.atan(a, rounding)
BigDecimal.sqrt(a, rounding)
The rounding
argument may look like {maximumFractionDigits: 10, roundingMode: "half-even"}
or {maximumSignificantDigits: 10, roundingMode: "half-even"}
,
where the roundingMode
can be:
"floor"
"down"
"ceil"
"up"
"half-even"
"half-up"
"half-down"
.Similar to BigDecimal, but uses base 2.
import {BigDecimal} from "./node_modules/@yaffle/bigdecimal/BigDecimal.js";
const rounding = {maximumSignificantDigits: 1000, roundingMode: "half-even"};
let pi = BigDecimal.multiply(BigDecimal.BigDecimal(4), BigDecimal.atan(BigDecimal.BigDecimal(1), rounding));
console.log(pi.toString());
BigDecimal.round(a, {maximumFractionDigits: 0, roundingMode: "half-even"})
.Results of running the benchmark from https://github.com/munsocket/jampary#early-stage-results-without-wasm-and-fma :
library | time |
---|---|
Jampary_Wasm | 466 ms |
Jampary | 204 ms |
BigNumberJs | 263 ms |
DecimalJs | 424 ms |
BigFloat | 85 ms |
BigDecimal | 135 ms |
BigJs | 3403 ms |
BigFloat32 | 158 ms |
FAQs
Arbitrary precision decimal arithmetic library. Polyfill for decimal proposal. Implemented on the top of BigInt.
We found that @yaffle/bigdecimal demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.