math-exact

Precision math for JavaScript/TypeScript

Usage no npm install needed!

<script type="module">
  import mathExact from 'https://cdn.skypack.dev/math-exact';
</script>

README

Math Exact (Floating Point Math)

npm version npm downloads

Features

  • ✅ Built with TypeScript
  • ✅ Tested with Jest

Built With

Pending Items

Getting Started

1. Install Package:

npm i math-exact

Example Code

Add:

// Imports: Dependencies
import { mathExact } from 'math-exact';

mathExact('Add', 1, 2); // 3
mathExact('Add', .1, .2);  // .3
mathExact('Add', 1.123, .2);  // 1.323
mathExact('Add', .02, 1.123); // 1.143

Subtract:

// Imports: Dependencies
import { mathExact } from 'math-exact';

mathExact('Subtract', 1, 2): // -1
mathExact('Subtract', .1, .2);  // -.1
mathExact('Subtract', 1.123, .2);  // .923
mathExact('Subtract', .02, 1.123); // -1.103

Multiply:

// Imports: Dependencies
import { mathExact } from 'math-exact';

mathExact('Multiply', 1, 2); // 2
mathExact('Multiply', .1, .2);  // .02
mathExact('Multiply', 1.123, .2);  // .2246
mathExact('Multiply', .02, 1.123); // .002246

Divide:

// Imports: Dependencies
import { mathExact } from 'math-exact';

mathExact('Divide', 1, 2); // .5
mathExact('Divide', .1, .2);  // .5
mathExact('Divide', 1.123, .2);  // 5.615
mathExact('Divide', .02, 1.123); // .017809439002671415

Changelog

[1.0.5] - 12/11/2020

Changed

  • Fixed build file issue.

[1.0.4] - 12/11/2020

Changed

  • Changed decimal points from 17 to 15.

[1.0.3] - 12/11/2020

Changed

  • Fixed build file issue.
  • Updated README example code.

[1.0.2] - 12/10/2020

Changed

  • Updated README title & example code.

[1.0.1] - 12/10/2020

Changed

  • Updated README example code.