math-hacker

Library to hack native Math

Usage no npm install needed!

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

README

math-hacker

Library to hack native Math

npm

version status devDependencies

API

var math = require('math-hacker')

math.precision(num)

math.precision(0) // 0
math.precision(0.1) // 1

math.add(a, b)

math.add(1, 2)
// 3

math.add(0.34, 0.01)
// 0.35
// In chrome 45.0.2454.99, 0.34 + 0.01 will output 0.35000000000000003

math.add(1.1111, -1.11)
// 0.0011
// In chrome 45.0.2454.99, 1.1111 - 1.11 will output 0.0010999999999998789

math.toFixed(num, precision)

math.toFixed(2.385, 2)
// "2.39"
// In chrome 45.0.2454.99, (2.385).toFixed(2) will output "2.38"

math.toFixed(2.384, 2)
// "2.38"

math.toFixed(2, 2)
// "2.00"