@exante/big-decimal
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

BigDecimal number converter

A very small set of utility functions to convert numbers in Big Decimal format to JavaScript numbers and back.

version styled with prettier

Install

npm install --save @exante/big-decimal

Usage

import { toBigDec, fromBigDec } from '@exante/big-decimal';

fromBigDec({ scale: 2, value: 12345 }); // -> 123.45

toBigDec(123.45); // -> { scale: 2, value: 12345 }

Features

  • Robust: The library is tested to behave correctly with all kinds of input. It correctly handles all JavaScript quirks when dealing with numbers and accounts for strings, scientific notation, leading and trailing zeros and invalid input.
  • Lightweight: 800 bytes minified

NOTE: Does not provide BigDecimal arithmetic

This library is intended to be as lightweight as possible. Therefore it only provides helpers to convert numbers to and from BigDecimal format. It does not provide utilities for BigDecimal arithmetic. If you need precision arithmetic in JavaScript, take a look at big.js or bignumber.js

Package Sidebar

Install

npm i @exante/big-decimal

Weekly Downloads

6

Version

1.0.3

License

MIT

Unpacked Size

9.01 kB

Total Files

13

Last publish

Collaborators

  • chicoxyzzy
  • everdimension
  • vden77