0.0.1 • Published 10 months ago

@abw/badger-maths v0.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Badger Maths

This library implements some basic mathematical functions that work around the imprecision in the IEEE 754 standard which Javascript uses for floating point numbers.

They were originally written using a fixed floating point algorithm based on the code in Sinful.js.

They are now implemented as Typescript wrappers around big.js.

Installation

Install badger-maths using your favourite package manager.

npm

npm add @abw/badger-maths

pnpm

pnpm add @abw/badger-maths

yarn

yarn add @abw/badger-maths

Quick Start

Import the add, subtract, multiply and/or divide functions from @abw/badger-maths.

import { add, subtract, multiply, divide } from '@abw/badger-maths'

Then use them to add, subtract, multiple or divide two or more numbers.

add(1.1, 6.6, 0.1);         // 1.1 + 6.6 + 0.1 => 7.8
subtract(7.8, 0.1, 2.4);    // 7.8 - 0.1 - 2.4 => 5.3
multiply(3.0, 2.2, 2.0);    // 3.0 * 2.2 * 2.0 => 13.2
divide(13.2, 2.0, 1.1);     // 13.2 / 2.0 / 1.1 => 6

Documentation

Visit the website for detailed documentation.

Author

Andy Wardley abw@wardley.org

0.0.1

10 months ago