
Research
/Security News
Fake imToken Chrome Extension Steals Seed Phrases via Phishing Redirects
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.
bigdecimal.js
Advanced tools
BigInt based BigDecimal implementation for Node.js 10.4 and above. This implementation is inspired from java BigDecimal class. This implementation is faster than popular big decimal libraries for most operations. See benchmarks results part below for comparison of each operation.
npm install bigdecimal.js
// Single unified constructor for multiple values
const { Big } = require('bigdecimal.js');
// Construct from a string and clone it
const x = Big('1.1111111111111111111111');
const y = new Big(x); // you can also use 'new'
const z = x.add(y);
console.log(z.toString()); // 2.2222222222222222222222
// You can also construct from a number or BigInt:
const u = Big(1.1);
const v = Big(2n);
console.log(u.toString()); // 1.1
console.log(v.toString()); // 2
You can use MathContext to set precision and rounding mode for a specific operation:
const { Big, MC, RoundingMode } = require('bigdecimal.js');
const x = Big('1');
const y = Big('3');
// MC is MathContext constructor that can be used with or without `new`
const res1 = x.divideWithMathContext(y, MC(3));
console.log(res1.toString()); // 0.333
const res2 = x.divideWithMathContext(y, new MC(3, RoundingMode.UP));
console.log(res2.toString()); // 0.334
try {
x.divide(y);
// throws since full precision is requested but it is not possible
} catch (e) {
console.log(e); // RangeError: Non-terminating decimal expansion; no exact representable decimal result.
}
npm inpm run compilenpm testThere is a benchmark suite that compares
To run the benchmark run npm install and then npm run benchmark.
For now, benchmarked against big.js and bigdecimal.
Test Machine:
Update Date: January 28th 2024
Library versions used:
Each operation is run with fixed set of decimal numbers composed of both simple and complex numbers.
Micro benchmark framework used is benchmark. Check out benchmarks folder for source code of benchmarks.
For now, benchmarked the following operations, more operations will be added later.
Operations per second(op/s):
| Operation | Bigdecimal.js | Big.js | BigNumber.js | decimal.js | GWTBased |
|---|---|---|---|---|---|
| Constructor | 43,962 ( - ) | 38,238 (-13%) | 42,337 (-4%) | 42,355 (-4%) | 2,818 (-94%) |
| Add | 80,569 ( - ) | 18,406 (-77%) | 100,734 (+25%) | 59,815 (-26%) | 90 (-100%) |
| Subtract | 73,518 ( - ) | 18,265 (-75%) | 96,022 (+31%) | 57,130 (-22%) | 89 (-100%) |
| Multiply | 493,291 ( - ) | 33,422 (-93%) | 26,810 (-95%) | 79,995 (-84%) | 2,609 (-99%) |
| Divide | 15,341 ( - ) | 1,129 (-93%) | 11,721 (-24%) | 13,301 (-13%) | 645 (-96%) |
| Remainder | 9,362 ( - ) | 3,816 (-59%) | 13,470 (+44%) | 21,952 (+134%) | 2,445 (-74%) |
| Positive pow | 27,403 ( - ) | 25 (-100%) | 113 (-100%) | 3,535 (-87%) | 6 (-100%) |
| Negative pow | 4,863 ( - ) | 21 (-100%) | 109 (-98%) | 1,970 (-59%) | 264 (-95%) |
| Abs | 782,251 ( - ) | 1,424,376 (+82%) | 917,526 (+17%) | 358,678 (-54%) | 14,132 (-98%) |
| Compare | 546,243 ( - ) | 1,216,388 (+123%) | 783,432 (+43%) | 417,873 (-24%) | 990,187 (+81%) |
FAQs
A BigDecimal implementation with native BigInts
The npm package bigdecimal.js receives a total of 2,381 weekly downloads. As such, bigdecimal.js popularity was classified as popular.
We found that bigdecimal.js demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Research
/Security News
Mixed-script homoglyphs and a lookalike domain mimic imToken’s import flow to capture mnemonics and private keys.

Security News
Latio’s 2026 report recognizes Socket as a Supply Chain Innovator and highlights our work in 0-day malware detection, SCA, and auto-patching.

Company News
Join Socket for live demos, rooftop happy hours, and one-on-one meetings during BSidesSF and RSA 2026 in San Francisco.