float-calculator

1.1.0 • Public • Published

Introduction

Perform addition, subtraction, multiplication and division operations for floating point numbers.

Documentation

Results when performing operations with javascript.
5.33 + 5.2 === 10.530000000000001
8.13 - 5.75 === 2.380000000000001
8.38 * 0.3 === 2.5140000000000002
4.2 / 1.2 === 3.5000000000000004

Result when performing with float-calculator

mathCalculation("+",5.33, 5.2 ) === 10.53
mathCalculation("-",8.13, 5.75 ) === 2.38
mathCalculation("*",8.38, 0.3) === 2.514
mathCalculation("/",4.2, 1.2 )=== 3.5

Why you need it? if you're dealing with sensitive stuff like monetary transactions, and you don't need to lose the last digits of numbers with methods like toFixed().

Install

npm i float-calculator 

Usage

import mathCalculation from "float-calculator";
mathCalculation("+",1.2,2,3)
mathCalculation("-",1.2,2,3)
mathCalculation("*",1.2,2,3)
mathCalculation("/",1.2,2,3)

Package Sidebar

Install

npm i float-calculator

Weekly Downloads

0

Version

1.1.0

License

ISC

Unpacked Size

2.36 kB

Total Files

3

Last publish

Collaborators

  • tuceo