New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

math-absolute-difference

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

math-absolute-difference

Computes the absolute difference of two real numbers.

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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.

Keywords

compute.io

FAQs

Package last updated on 12 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts