JSPM

math-absolute-difference

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q27717F
  • License MIT

Computes the absolute difference of two real numbers.

Package Exports

  • math-absolute-difference

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (math-absolute-difference) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Absolute Difference

NPM version Build Status Coverage Status Dependencies

Computes the absolute difference of two real numbers.

The absolute difference of two real numbers is defined as the absolute value of their difference.

Absolute difference

Installation

$ npm install math-absolute-difference

Usage

var diff = require( 'math-absolute-difference' );

diff( x, y )

Computes the absolute difference of two real numbers.

var d = diff( 2, 5 );
// returns 3

d = diff( -1, 3.14 );
// returns ~4.14

d = diff( 10.1, -2.05 );
// returns ~12.15

d = diff( -0, 0 );
// returns 0

d = diff( NaN, 5 );
// returns NaN

d = diff( 5, NaN );
// returns NaN

var PINF = Number.POSITIVE_INFINITY;
var NINF = Number.NEGATIVE_INFINITY;

d = diff( PINF, PINF );
// returns NaN

d = diff( NINF, NINF );
// returns NaN

d = diff( PINF, NINF );
// returns +infinity

d = diff( NINF, PINF );
// returns +infinity

Examples

var diff = require( 'math-absolute-difference' );

var x;
var y;
var d;
var i;

for ( i = 0; i < 100; i++ ) {
    x = Math.random()*1e4 - 1e2;
    y = Math.random()*1e4 - 1e2;
    d = diff( x, y );
    console.log( 'x = %d. y = %d. |x-y| = %d.', x, y, d );
}

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

This repository uses tape for unit tests. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

Browser Support

This repository uses Testling for browser testing. To run the tests in a (headless) local web browser, execute the following command in the top-level application directory:

$ make test-browsers

To view the tests in a local web browser,

$ make view-browser-tests

License

MIT license.

Copyright © 2016. The Compute.io Authors.