Node module for handling float numbers
JavaScript
Latest commit 67df4ad Oct 14, 2014 @mex Fixed test coverage badge
Failed to load latest commit information.
coverage Added test coverage Oct 14, 2014
src
tests
.gitignore Added test coverage Oct 14, 2014
.travis.yml
README.md
bower.json v1.0.1 Aug 19, 2014
package.json

README.md

Float

Build Status Code Climate Test Coverage

GitHub repository: github.com/mex/float

NPM package: npmjs.org/package/float

Install

Install through NPM: npm install float

Install through Bower: bower install float

Usage

var f = require('float');

var a = 2.15;
var b = 3.46;
var c = 5.61;
var ab = f.round(a + b);
if (f.equals(ab, c) {
  console.log('They are equal!');
} else {
  console.log('Someone clearly failed at some point...');
}

Documentation

  • round(number, precision)
    • Rounds the number to the given number of decimals.
    • Parameters:
      • number (float)
      • precision (integer): Number of decimals
    • Return:
      • float
  • floor(number, precision)
    • Floors the number to the given number of decimals.
    • Parameters:
      • number (float)
      • precision (integer): Number of decimals
    • Return:
      • float
  • ceil(number, precision)
    • Ceils the number to the given number of decimals.
    • Parameters:
      • number (float)
      • precision (integer): Number of decimals
    • Return:
      • float
  • equals(a, b[, d])
    • Compares the arguments and return whether they are equal.
    • Parameters:
      • a (float)
      • b (float)
      • d (integer): Number of decimals
    • Return:
      • boolean
  • lessThan(a, b[, d])
    • Compares the arguments and return whether a is less than b.
    • Parameters:
      • a (float)
      • b (float)
      • d (integer): Number of decimals
    • Return:
      • boolean
  • lessThanOrEquals(a, b[, d])
    • Compares the arguments and return whether a is less than or equal to b.
    • Parameters:
      • a (float)
      • b (float)
      • d (integer): Number of decimals
    • Return:
      • boolean
  • greaterThan(a, b[, d])
    • Compares the arguments and return whether a is greater than b.
    • Parameters:
      • a (float)
      • b (float)
      • d (integer): Number of decimals
    • Return:
      • boolean
  • greaterThanOrEquals(a, b[, d])
    • Compares the arguments and return whether a is greater than or equal to b.
    • Parameters:
      • a (float)
      • b (float)
      • d (integer): Number of decimals
    • Return:
      • boolean