Scale function name.
The following scale
functions are supported:
x
and y
(default).x
and y
.x
and y
.x
and y
.x
and y
.x
and y
.x
(noncommutative).y
(noncommutative).Computes the relative difference in units of double-precision floating-point epsilon.
x
and y
. To scale by a different function, specify a scale function name or custom scale function.x
and y
is 0
, the relative difference is always 0
.|x| = |y| = infinity
, the function returns NaN
.|x| = |-y| = infinity
, the relative difference is +infinity
.scale
function returns 0
, the function returns NaN
.first number
second number
scale function (default: 'max-abs')
relative difference in units of double-precision floating-point epsilon
var d = epsilonDifference( 12.15, 12.149999999999999 ); // => ~0.658ε
// returns ~0.658
var d = epsilonDifference( 2.4341309458983933, 2.4341309458633909, 'mean-abs' ); // => ~64761.5ε => ~1.438e-11
// returns ~64761.5
function scale( x, y ) {
// Return the minimum value:
return ( x > y ) ? y : x;
}
var d = epsilonDifference( 1.0000000000000002, 1.0000000000000100, scale ); // => ~44ε
// returns ~44
Custom scale function.
first value
second value
custom scale