diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/README.md b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/README.md new file mode 100644 index 000000000000..acd652829a39 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/README.md @@ -0,0 +1,146 @@ + + +# ulpdiff + +> Compute the number of representable [single-precision][single-precision] floating-point values that separate two [single-precision][single-precision] floating-point numbers along the real number line. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); +``` + +#### ulpdiff( x, y ) + +Computes the number of representable [single-precision][single-precision] floating-point values that separate two [single-precision][single-precision] floating-point numbers along the real number line. + +```javascript +var EPS = require( '@stdlib/constants/float32/eps' ); + +var d = ulpdiff( 1.0, 1.0+EPS ); +// returns 1.0 + +d = ulpdiff( 1.0+EPS, 1.0 ); +// returns 1.0 + +d = ulpdiff( 1.0, 1.0+EPS+EPS ); +// returns 2.0 + +d = ulpdiff( 1.0, NaN ); +// returns NaN + +d = ulpdiff( NaN, 1.0 ); +// returns NaN + +d = ulpdiff( NaN, NaN ); +// returns NaN +``` + +
+ + + + + +
+ +## Notes + +- Adjacent [single-precision][single-precision] floating-point numbers differ by `1` [ulp][ulp] (unit in the last place). +- Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is `0`. + +
+ + + + + +
+ +## Examples + + + +```javascript +var EPS = require( '@stdlib/constants/float32/eps' ); +var SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); +var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); + +var d = ulpdiff( 1.0, 1.0+EPS ); +console.log( d ); +// => 1.0 + +d = ulpdiff( 5.8364e-31, 5.8367e-31 ); +console.log( d ); +// => 638.0 + +d = ulpdiff( 0.0, SMALLEST_SUBNORMAL ); +console.log( d ); +// => 1.0 + +d = ulpdiff( 0.0, -0.0 ); +console.log( d ); +// => 0.0 + +d = ulpdiff( SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL ); +console.log( d ); +// => 2.0 +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/benchmark/benchmark.js new file mode 100644 index 000000000000..a2626d69cde2 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/benchmark/benchmark.js @@ -0,0 +1,57 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var bench = require( '@stdlib/bench' ); +var uniform = require( '@stdlib/random/array/uniform' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var pkg = require( './../package.json' ).name; +var ulpdiff = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var opts; + var x; + var y; + var i; + + opts = { + 'dtype': 'float32' + }; + x = uniform( 100, -500.0, 500.0, opts ); + y = uniform( 100, -500.0, 500.0, opts ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = ulpdiff( x[ i%x.length ], y[ i%y.length ] ); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( y ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/repl.txt b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/repl.txt new file mode 100644 index 000000000000..d544a1d774c0 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/repl.txt @@ -0,0 +1,45 @@ + +{{alias}}( x, y ) + Computes the number of representable single-precision floating-point values + that separate two single-precision floating-point numbers along the real + number line. + + Adjacent single-precision floating-point numbers differ by 1 ulp (unit in + the last place). + + Signed zeros differ only in the sign bit but are considered numerically + equal, and thus their ULP difference is 0. + + If provided `NaN` as any argument, the function returns `NaN`. + + Parameters + ---------- + x: number + First input value. + + y: number + Second input value. + + Returns + ------- + z: number + Result. + + Examples + -------- + > var v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float32/eps}} ) + 1.0 + > v = {{alias}}( 1.0+{{alias:@stdlib/constants/float32/eps}}, 1.0 ) + 1.0 + > v = {{alias}}( 1.0, 1.0+{{alias:@stdlib/constants/float32/eps}}*2.0 ) + 2.0 + > v = {{alias}}( 1.0, NaN ) + NaN + > v = {{alias}}( NaN, 1.0 ) + NaN + > v = {{alias}}( NaN, NaN ) + NaN + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/index.d.ts new file mode 100644 index 000000000000..05c3548c03c8 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/index.d.ts @@ -0,0 +1,59 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +// TypeScript Version: 4.1 + +/** +* Computes the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line. +* +* ## Notes +* +* - Adjacent single-precision floating-point numbers differ by 1 ulp (unit in the last place). +* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0. +* +* @param x - first input value +* @param y - second input value +* @returns result +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* +* var d = ulpdiff( 1.0, 1.0+EPS ); +* // returns 1.0 +* +* d = ulpdiff( 1.0+EPS, 1.0 ); +* // returns 1.0 +* +* d = ulpdiff( 1.0, 1.0+EPS+EPS ); +* // returns 2.0 +* +* d = ulpdiff( 1.0, NaN ); +* // returns NaN +* +* d = ulpdiff( NaN, 1.0 ); +* // returns NaN +* +* d = ulpdiff( NaN, NaN ); +* // returns NaN +*/ +declare function ulpdiff( x: number, y: number ): number; + + +// EXPORTS // + +export = ulpdiff; diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/test.ts b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/test.ts new file mode 100644 index 000000000000..239f60260c44 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/docs/types/test.ts @@ -0,0 +1,58 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +import ulpdiff = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + ulpdiff( 8.0, 8.0 ); // $ExpectType number +} + +// The compiler throws an error if the function is provided a first argument which is not a number... +{ + ulpdiff( true, 5.0 ); // $ExpectError + ulpdiff( false, 5.0 ); // $ExpectError + ulpdiff( null, 5.0 ); // $ExpectError + ulpdiff( undefined, 5.0 ); // $ExpectError + ulpdiff( '5', 5.0 ); // $ExpectError + ulpdiff( [], 5.0 ); // $ExpectError + ulpdiff( {}, 5.0 ); // $ExpectError + ulpdiff( ( x: number ): number => x, 5.0 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a number... +{ + ulpdiff( 5.0, true ); // $ExpectError + ulpdiff( 5.0, false ); // $ExpectError + ulpdiff( 5.0, null ); // $ExpectError + ulpdiff( 5.0, undefined ); // $ExpectError + ulpdiff( 5.0, '5' ); // $ExpectError + ulpdiff( 5.0, [] ); // $ExpectError + ulpdiff( 5.0, {} ); // $ExpectError + ulpdiff( 5.0, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + ulpdiff(); // $ExpectError + ulpdiff( 5.0 ); // $ExpectError + ulpdiff( 5.0, 5.0, 5.0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/examples/index.js b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/examples/index.js new file mode 100644 index 000000000000..68ec6bf537e1 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/examples/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +var EPS = require( '@stdlib/constants/float32/eps' ); +var SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); +var ulpdiff = require( './../lib' ); + +var d = ulpdiff( 1.0, 1.0+EPS ); +console.log( d ); +// => 1.0 + +d = ulpdiff( 5.8364e-31, 5.8367e-31 ); +console.log( d ); +// => 638.0 + +d = ulpdiff( 0.0, SMALLEST_SUBNORMAL ); +console.log( d ); +// => 1.0 + +d = ulpdiff( 0.0, -0.0 ); +console.log( d ); +// => 0.0 + +d = ulpdiff( SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL ); +console.log( d ); +// => 2.0 diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/index.js b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/index.js new file mode 100644 index 000000000000..38f00e96d61f --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/index.js @@ -0,0 +1,56 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +/** +* Compute the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line. +* +* @module @stdlib/number/float32/base/ulp-difference +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* var ulpdiff = require( '@stdlib/number/float32/base/ulp-difference' ); +* +* var d = ulpdiff( 1.0, EPS ); +* // returns 1.0 +* +* d = ulpdiff( EPS, 1.0 ); +* // returns 1.0 +* +* d = ulpdiff( 1.0, EPS+EPS ); +* // returns 2.0 +* +* d = ulpdiff( 1.0, NaN ); +* // returns NaN +* +* d = ulpdiff( NaN, 1.0 ); +* // returns NaN +* +* d = ulpdiff( NaN, NaN ); +* // returns NaN +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/main.js b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/main.js new file mode 100644 index 000000000000..04aeb29c64f0 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/lib/main.js @@ -0,0 +1,104 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); +var SIGN_MASK = require( '@stdlib/constants/float32/sign-mask' ); +var toWordf = require( '@stdlib/number/float32/base/to-word' ); +var abs = require( '@stdlib/math/base/special/abs' ); + + +// FUNCTIONS // + +/** +* Converts an unsigned 32-bit integer corresponding to the IEEE 754 binary representation of a single-precision floating-point number to a lexicographically ordered integer. +* +* @private +* @param {unsigned32} word - unsigned 32-bit integer +* @returns {integer} lexicographically ordered integer +*/ +function monotoneKey( word ) { + if ( word & SIGN_MASK ) { // x < 0 + return ( ~word + 1 ); // two's-complement negation + } + // x >= 0 + return ( word | SIGN_MASK ) >>> 0; // push +0 to just above -0 +} + + +// MAIN // + +/** +* Computes the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line. +* +* ## Notes +* +* - Adjacent single-precision floating-point numbers differ by 1 ulp (unit in the last place). +* - Signed zeros differ only in the sign bit but are considered numerically equal, and thus their ULP difference is 0. +* +* @param {number} x - first value +* @param {number} y - second value +* @returns {number} result +* +* @example +* var EPS = require( '@stdlib/constants/float32/eps' ); +* +* var d = ulpdiff( 1.0, 1.0+EPS ); +* // returns 1.0 +* +* d = ulpdiff( 1.0+EPS, 1.0 ); +* // returns 1.0 +* +* d = ulpdiff( 1.0, 1.0+EPS+EPS ); +* // returns 2.0 +* +* d = ulpdiff( 1.0, NaN ); +* // returns NaN +* +* d = ulpdiff( NaN, 1.0 ); +* // returns NaN +* +* d = ulpdiff( NaN, NaN ); +* // returns NaN +*/ +function ulpdiff( x, y ) { + var wx; + var wy; + + if ( isnanf( x ) || isnanf( y ) ) { + return NaN; + } + // Convert input values to unsigned 32-bit integers corresponding to the IEEE 754 binary representation of single-precision floating-point numbers: + wx = toWordf( x ); + wy = toWordf( y ); + + // Convert the words to lexicographically ordered integers: + wx = monotoneKey( wx ); + wy = monotoneKey( wy ); + + // Return a double as a result, which can exactly represent the ULP difference for all representable single-precision floating-point numbers: + return abs( wx - wy ); +} + + +// EXPORTS // + +module.exports = ulpdiff; diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/package.json b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/package.json new file mode 100644 index 000000000000..21581b3c3f9f --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/number/float32/base/ulp-difference", + "version": "0.0.0", + "description": "Compute the number of representable single-precision floating-point values that separate two single-precision floating-point numbers along the real number line.", + "license": "Apache-2.0", + "author": { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + }, + "contributors": [ + { + "name": "The Stdlib Authors", + "url": "https://github.com/stdlib-js/stdlib/graphs/contributors" + } + ], + "main": "./lib", + "directories": { + "benchmark": "./benchmark", + "doc": "./docs", + "example": "./examples", + "lib": "./lib", + "test": "./test" + }, + "types": "./docs/types", + "scripts": {}, + "homepage": "https://github.com/stdlib-js/stdlib", + "repository": { + "type": "git", + "url": "git://github.com/stdlib-js/stdlib.git" + }, + "bugs": { + "url": "https://github.com/stdlib-js/stdlib/issues" + }, + "dependencies": {}, + "devDependencies": {}, + "engines": { + "node": ">=0.10.0", + "npm": ">2.7.0" + }, + "os": [ + "aix", + "darwin", + "freebsd", + "linux", + "macos", + "openbsd", + "sunos", + "win32", + "windows" + ], + "keywords": [ + "stdlib", + "stdmath", + "mathematics", + "math", + "relative", + "difference", + "abs", + "diff", + "error", + "distance", + "dist", + "numbers", + "ulp", + "float32", + "double" + ] +} diff --git a/lib/node_modules/@stdlib/number/float32/base/ulp-difference/test/test.js b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/test/test.js new file mode 100644 index 000000000000..d8328248ecbb --- /dev/null +++ b/lib/node_modules/@stdlib/number/float32/base/ulp-difference/test/test.js @@ -0,0 +1,112 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2025 The Stdlib Authors. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +'use strict'; + +// MODULES // + +var tape = require( 'tape' ); +var isnan = require( '@stdlib/math/base/assert/is-nan' ); +var isPositiveFinite = require( '@stdlib/assert/is-positive-finite' ); +var EPS = require( '@stdlib/constants/float32/eps' ); +var SMALLEST_SUBNORMAL = require( '@stdlib/constants/float32/smallest-subnormal' ); +var PINF = require( '@stdlib/constants/float32/pinf' ); +var NINF = require( '@stdlib/constants/float32/ninf' ); +var ulpdiff = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof ulpdiff, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns the ULP difference between two double-precision floating-point numbers', function test( t ) { + t.strictEqual( ulpdiff( 1.0, 1.0+EPS ), 1.0, 'returns expected value' ); + t.strictEqual( ulpdiff( 1.0+EPS, 1.0 ), 1.0, 'returns expected value' ); + + t.strictEqual( ulpdiff( 1.0, 1.0+( EPS*2.0 ) ), 2.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -1.0, -1.0+EPS ), 2.0, 'returns expected value' ); + + t.strictEqual( ulpdiff( -1.0, -1.0-( EPS*2.0 ) ), 2.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -1.0, -1.0+( EPS*2.0 ) ), 4.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function handles signed zeros', function test( t ) { + t.strictEqual( ulpdiff( 0.0, -0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -0.0, 0.0 ), 0.0, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `0` for identical values', function test( t ) { + t.strictEqual( ulpdiff( 5.0, 5.0 ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -5.0, -5.0 ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( 0.0, 0.0 ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -0.0, -0.0 ), 0.0, 'returns expected value' ); + + t.strictEqual( ulpdiff( SMALLEST_SUBNORMAL, SMALLEST_SUBNORMAL ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL ), 0.0, 'returns expected value' ); + + t.strictEqual( ulpdiff( PINF, PINF ), 0.0, 'returns expected value' ); + t.strictEqual( ulpdiff( NINF, NINF ), 0.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function handles infinities', function test( t ) { + t.strictEqual( isPositiveFinite( ulpdiff( 5.0, PINF ) ), true, 'returns expected value' ); + t.strictEqual( isPositiveFinite( ulpdiff( PINF, 5.0 ) ), true, 'returns expected value' ); + + t.strictEqual( isPositiveFinite( ulpdiff( 5.0, NINF ) ), true, 'returns expected value' ); + t.strictEqual( isPositiveFinite( ulpdiff( NINF, 5.0 ) ), true, 'returns expected value' ); + + t.strictEqual( isPositiveFinite( ulpdiff( PINF, NINF ) ), true, 'returns expected value' ); + t.strictEqual( isPositiveFinite( ulpdiff( NINF, PINF ) ), true, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function handles subnormal numbers', function test( t ) { + t.strictEqual( ulpdiff( SMALLEST_SUBNORMAL, 0.0 ), 1.0, 'returns expected value' ); + t.strictEqual( ulpdiff( 0.0, SMALLEST_SUBNORMAL ), 1.0, 'returns expected value' ); + + t.strictEqual( ulpdiff( SMALLEST_SUBNORMAL, -SMALLEST_SUBNORMAL ), 2.0, 'returns expected value' ); + t.strictEqual( ulpdiff( -SMALLEST_SUBNORMAL, SMALLEST_SUBNORMAL ), 2.0, 'returns expected value' ); + + t.end(); +}); + +tape( 'if provided a `NaN`, the function returns `NaN`', function test( t ) { + t.strictEqual( isnan( ulpdiff( NaN, 5.0 ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( NaN, PINF ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( NaN, NINF ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( NaN, SMALLEST_SUBNORMAL ) ), true, 'returns expected value' ); + + t.strictEqual( isnan( ulpdiff( 5.0, NaN ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( PINF, NaN ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( NINF, NaN ) ), true, 'returns expected value' ); + t.strictEqual( isnan( ulpdiff( SMALLEST_SUBNORMAL, NaN ) ), true, 'returns expected value' ); + + t.strictEqual( isnan( ulpdiff( NaN, NaN ) ), true, 'returns expected value' ); + + t.end(); +});