Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
@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)
a.toPrecision(precision)
a.toExponential(fractionDigits)
BigDecimal.toBigInt(a) // (not in the spec)
BigDecimal.toNumber(a) // (not in the spec, only integers)
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.equal(a, b)
BigDecimal.lessThan(a, b)
BigDecimal.greaterThan(a, b)
BigDecimal.log(a, rounding)
BigDecimal.exp(a, rounding)
BigDecimal.sin(a, rounding)
BigDecimal.cos(a, rounding)
BigDecimal.atan(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", or "ceil", or "half-even", or "half-up".
Similar to BigDecimal, but uses base 2.
import {BigDecimal} from "./node_modules/@yaffle/bigdecimal/BigDecimal.js";
var pi = BigDecimal.multiply(BigDecimal.BigDecimal(4), BigDecimal.atan(BigDecimal.BigDecimal(1), {maximumSignificantDigits: 1000, roundingMode: "half-even"}));
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 | 73 ms |
BigDecimal | 322 ms |
BigJs | 3403 ms |
BigFloat32 | 158 ms |
FAQs
Arbitrary precision decimal arithmetic library. Polyfill for decimal proposal. Implemented on the top of BigInt.
The npm package @yaffle/bigdecimal receives a total of 17 weekly downloads. As such, @yaffle/bigdecimal popularity was classified as not popular.
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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.