1.4.3 • Published 10 years ago

better-math v1.4.3

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

better-math

Mathematical operations performed reliably and intuitively

PRs Welcome MIT License npm downloads

js-standard-style

Why?

  • No ugly approximation:
	0.1 + 0.2 // => 0.30000000000000004
	math.add(0.1, 0.2) // => 0.3
  • No messy unpredictable type conversion:
	1 + '1' // => '11'
	true - 1 // => 0
	[] + 1.1 // => '1.1'
	[] - 1.1 // => '-1.1'
	{} + 1.1 // => 1.1

	math.add(1, '1') // => Uncaught Error: Both arguments must be finite numbers
	math.add(true, -1) // => Uncaught Error: Both arguments must be finite numbers
	math.add([], 1.1) // => Uncaught Error: Both arguments must be finite numbers
	math.add([], 1.1) // => Uncaught Error: Both arguments must be finite numbers
	math.add({}, 1.1) // => Uncaught Error: Both arguments must be finite numbers

Install

$ npm install --save better-math

Usage

var math = require('better-math')

math.add(0.1, 0.2) // => 0.3
math.add(0.1, -0.2) // => -0.1

API

math.add (number1, number2)

number1, number2

Type: real number for both arguments strictly enforced with no exceptions!

No Infinities, no NaNs, no null, no strings (not even '1'!):

  if (!isFinite(x) || !isFinite(y)) throw Error('Both arguments must be finite numbers')

Status

Currently .add is implemented and thoroughly tested

Credit

License

MIT © Dmitri Zaitsev

1.4.3

10 years ago

1.4.2

10 years ago

1.4.1

10 years ago

1.3.1

10 years ago

1.2.1

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago