# decimath

> Small, Simple library for Precise Decimal Calculations

Latest version **1.1.1** (published 2021-02-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install decimath
pnpm add decimath
yarn add decimath
bun add decimath
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.1 |
| Published | 2021-02-09 |
| First published | 2021-01-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 7.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | CADawg |
| Maintainers | snaddyvitch-dispenser |
| Keywords | decimals, math, maths |

## Links

- npm: https://www.npmjs.com/package/decimath
- Repository: https://github.com/Snaddyvitch-Dispenser/decimath
- Homepage: https://github.com/Snaddyvitch-Dispenser/decimath#readme
- Issues: https://github.com/Snaddyvitch-Dispenser/decimath/issues
- npm.io page: https://npm.io/package/decimath

## Alternatives

- [random-seedable](https://npm.io/package/random-seedable.md) — 27.9K weekly downloads
- [n2words](https://npm.io/package/n2words.md) — 22.2K weekly downloads
- [@stdlib/math-base-special-factorialln](https://npm.io/package/@stdlib/math-base-special-factorialln.md) — 5.7K weekly downloads
- [@stdlib/math-base-special-abs2](https://npm.io/package/@stdlib/math-base-special-abs2.md) — 1.7K weekly downloads
- [commons-math-interpolation](https://npm.io/package/commons-math-interpolation.md) — 1.4K weekly downloads

## Recent versions

- 1.1.1 (latest) — 2021-02-09
- 1.1.0 — 2021-02-02
- 1.0.2 — 2021-01-28
- 1.0.1 — 2021-01-28
- 1.0.0 — 2021-01-28

## README

# DeciMath
A small JavaScript library for doing precise floating point maths

Sure, there are many maths libraries to tickle your fancy, but sometimes you just need proper floating point maths and nothing more, that's why this library exists.

## Install

### Node/React

```bash
npm install decimath
```

```bash
yarn add decimath
```

### Browser

Just copy and link to the file or include it in your scripts.

## Usage

Node Only:
```js
import BigNumber from 'decimath';
```

You'll need a `BigNumber` to make use of this. To make a new Big Number Use the following:

```js
let bn = BigNumber(0.1); // initial value
```

## Operations

All operations support a value as either a `BigNumber` or any other numeric type that can be converted to a `BigNumber`.

All operations except Power Of accept decimal values.

All operations return `this` to allow chaining. To Get the value, end the chain with `.valueOf()`

### Add

```js
bn.add(0.2); // adds 0.2 to our initial value
```

### Subtract

```js
bn.subtract(0.1); // Takes 0.1 from our value
```

### Multiply

```js
bn.multiply(100); // Multiplies value by 100
```

### Divide

```js
bn.divide(2.5); // Divides our value by 2.5
```

### Power of

```js
bn.pow(30); // bn to the power of 30
```

## Using calculated values outside of the library

Use `.valueOf()` to get the JS decimal version of the number

## Used By

[![](https://nftm.art/images/decorative/general/nftmart_wide_light_logo/onesize.png)](https://nftm.art)

## Live Preview

https://repl.it/@Snaddyvitch_Dis/Decimath-Testing

---
_Source: https://npm.io/package/decimath · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
