1.0.2 • Published 7 months ago
big-decimals v1.0.2
BDFactory
A TypeScript library for high-precision arithmetic operations and comparisons using the js-big-decimal
package.
Features
- High-precision arithmetic (addition, subtraction, multiplication, division)
- Comparison operations (
>
,>=
,==
,<
) - Rounding and trailing zero stripping
- Fluent API for chaining operations
Installation
Install the library and its dependency:
npm install big-decimal
import { BDFactory } from 'big-decimals';
const num = new BDFactory(10.5);
// Perform arithmetic operations
num.add(2).mul(3).sub(5).div(2);
console.log(num.getValue()); // Output: "16.25000000"
// Comparison
console.log(num.gt(10)); // true
console.log(num.lt(15)); // false
// Rounding
num.round(4);
console.log(num.getValue()); // Output: "16.2500"
// Strip trailing zeros
num.stripTrailingZero();
console.log(num.getValue()); // Output: "16.25"