@abw/badger-maths
v0.0.1
Published
This library implements some basic mathematical functions that work around the imprecision in the IEEE 754 standard which Javascript uses for floating point numbers.
Readme
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-mathspnpm
pnpm add @abw/badger-mathsyarn
yarn add @abw/badger-mathsQuick 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 => 6Documentation
Visit the website for detailed documentation.
Author
Andy Wardley [email protected]
