Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 17, 2024 via pnpm

decimal.js 10.4.3

An arbitrary-precision Decimal type for JavaScript.
Package summary
Share
0
issues
1
license
1
MIT
Package created
2 Apr 2014
Version published
4 Dec 2022
Maintainers
1
Total deps
1
Direct deps
0
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
1 Packages, Including:
decimal.js@10.4.3
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
ⓘ This is a list of decimal.js 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does decimal.js do?

Decimal.js is a precise and efficient JavaScript library used for integer and float computations. The essential functionality of the package includes arithmetic operations, hexadecimal, binary, and octal values handling, as well as implementing several of JavaScript's Number.prototype and Math methods. Unlike JavaScript's BigDecimal class, decimal.js focuses on significant digits rather than decimal places and ensures precise results even for non-integer powers. Designed for extensive platform compatibility, this library operates using JavaScript 1.5 (ECMAScript 3) features, minimizing dependencies and providing a light footprint for your projects.

How do you use decimal.js?

Using decimal.js in your project is straightforward and starts with installing the library. If you are working on a Node.js project, the installation can be done via npm using the command npm install decimal.js. Once installed, the package can be imported using built-in Node.js require() method:

const Decimal = require('decimal.js');

Or using ES6 import statements:

import Decimal from 'decimal.js';

The core functionality of decimal.js is accessed through the Decimal constructor, which can parse numbers, strings, or other Decimal instances. Due to precision considerations, it's often recommended to pass larger values as strings:

let x = new Decimal(123.4567);
let y = new Decimal('123456.7e-3');
let z = new Decimal(x);
console.log(x.equals(y) && y.equals(z) && x.equals(z));  // Outputs: true

Complex calculations can be chained:

let result = new Decimal(10).dividedBy(3).plus(7).times(5).floor();
console.log(result.toString());  // Outputs: '23'

Where are the decimal.js docs?

The complete documentation for decimal.js is available on the project’s GitHub page. You can find it here. The documentation contains details about the API, usage examples, and other intricate details about the library, ensuring you have access to all the information needed to seamlessly integrate this library into your projects.