From ee4df4151f2935e37c94754ded53f63fd8472399 Mon Sep 17 00:00:00 2001 From: Neeraj Pathak Date: Thu, 8 Jan 2026 11:00:28 +0530 Subject: [PATCH] feat: add initial setup --- .../base/assert/is-negative-zero/README.md | 92 +++++++++++++++++++ .../is-negative-zero/benchmark/benchmark.js | 55 +++++++++++ .../assert/is-negative-zero/docs/repl.txt | 24 +++++ .../is-negative-zero/docs/types/index.d.ts | 40 ++++++++ .../is-negative-zero/docs/types/test.ts | 46 ++++++++++ .../assert/is-negative-zero/examples/index.js | 36 ++++++++ .../base/assert/is-negative-zero/lib/index.js | 43 +++++++++ .../base/assert/is-negative-zero/lib/main.js | 49 ++++++++++ .../base/assert/is-negative-zero/package.json | 75 +++++++++++++++ .../base/assert/is-negative-zero/test/test.js | 67 ++++++++++++++ 10 files changed, 527 insertions(+) create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/README.md create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/examples/index.js create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/index.js create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/main.js create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/package.json create mode 100644 lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/test/test.js diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/README.md b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/README.md new file mode 100644 index 000000000000..e1b5ff17c940 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/README.md @@ -0,0 +1,92 @@ + + +# isNegativeZero + +> Test if a half-precision floating-point numeric value is negative zero. + +
+ +## Usage + +```javascript +var isNegativeZero = require( '@stdlib/number/float16/base/assert/is-negative-zero' ); +``` + +#### isNegativeZero( x ) + +Tests if a half-precision floating-point `numeric` value is negative zero. + +```javascript +var bool = isNegativeZero( -0.0 ); +// returns true + +bool = isNegativeZero( 0.0 ); +// returns false +``` + +
+ + + +
+ +## Examples + + + +```javascript +var isNegativeZero = require( '@stdlib/number/float16/base/assert/is-negative-zero' ); + +var bool = isNegativeZero( -0.0 ); +// returns true + +bool = isNegativeZero( 0.0 ); +// returns false + +bool = isNegativeZero( 5.0 ); +// returns false + +bool = isNegativeZero( -1.0 ); +// returns false + +bool = isNegativeZero( NaN ); +// returns false +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/benchmark/benchmark.js new file mode 100644 index 000000000000..ab89600f263b --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/benchmark/benchmark.js @@ -0,0 +1,55 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 toFloat16 = require( '@stdlib/number/float64/base/to-float16' ); +var map = require( '@stdlib/array/base/map' ); +var naryFunction = require( '@stdlib/utils/nary-function' ); +var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive; +var pkg = require( './../package.json' ).name; +var isNegativeZero = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var x; + var y; + var i; + + x = map( uniform( 100, -5.0e4, 5.0e4 ), naryFunction( toFloat16, 1 ) ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = isNegativeZero( x[ i%x.length ] ); + if ( typeof y !== 'boolean' ) { + b.fail( 'should return a boolean' ); + } + } + b.toc(); + if ( !isBoolean( y ) ) { + b.fail( 'should return a boolean' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/repl.txt b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/repl.txt new file mode 100644 index 000000000000..183489373223 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/repl.txt @@ -0,0 +1,24 @@ + +{{alias}}( x ) + Tests if a half-precision floating-point numeric value is negative zero. + + Parameters + ---------- + x: number + Value to test. + + Returns + ------- + bool: boolean + Boolean indicating whether the value is negative zero. + + Examples + -------- + > var bool = {{alias}}( -0.0 ) + true + > bool = {{alias}}( 0.0 ) + false + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/index.d.ts new file mode 100644 index 000000000000..965a0dcc1860 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/index.d.ts @@ -0,0 +1,40 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 + +/** +* Tests if a half-precision floating-point numeric value is negative zero. +* +* @param x - value to test +* @returns boolean indicating whether the value is negative zero +* +* @example +* var bool = isNegativeZero( -0.0 ); +* // returns true +* +* @example +* var bool = isNegativeZero( 0.0 ); +* // returns false +*/ +declare function isNegativeZero( x: number ): boolean; + + +// EXPORTS // + +export = isNegativeZero; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/test.ts b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/test.ts new file mode 100644 index 000000000000..0529db0f7564 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/docs/types/test.ts @@ -0,0 +1,46 @@ +/* +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isNegativeZero = require( './index' ); + + +// TESTS // + +// The function returns a boolean... +{ + isNegativeZero( 0 ); // $ExpectType boolean + isNegativeZero( -0 ); // $ExpectType boolean + isNegativeZero( 2 ); // $ExpectType boolean +} + +// The compiler throws an error if the function is provided a value other than a number... +{ + isNegativeZero( true ); // $ExpectError + isNegativeZero( false ); // $ExpectError + isNegativeZero( null ); // $ExpectError + isNegativeZero( undefined ); // $ExpectError + isNegativeZero( [] ); // $ExpectError + isNegativeZero( {} ); // $ExpectError + isNegativeZero( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + isNegativeZero(); // $ExpectError + isNegativeZero( undefined, 123 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/examples/index.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/examples/index.js new file mode 100644 index 000000000000..5bd79d327038 --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/examples/index.js @@ -0,0 +1,36 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isNegativeZero = require( './../lib' ); + +console.log( isNegativeZero( -0.0 ) ); +// => true + +console.log( isNegativeZero( 0.0 ) ); +// => false + +console.log( isNegativeZero( 5.0 ) ); +// => false + +console.log( isNegativeZero( -1.0 ) ); +// => false + +console.log( isNegativeZero( NaN ) ); +// => false diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/index.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/index.js new file mode 100644 index 000000000000..1240401f1f8b --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/index.js @@ -0,0 +1,43 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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'; + +/** +* Test if a half-precision floating-point numeric value is negative zero. +* +* @module @stdlib/number/float16/base/assert/is-negative-zero +* +* @example +* var isNegativeZero = require( '@stdlib/number/float16/base/assert/is-negative-zero' ); +* +* var bool = isNegativeZero( -0.0 ); +* // returns true +* +* bool = isNegativeZero( 0.0 ); +* // returns false +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/main.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/main.js new file mode 100644 index 000000000000..7e570274df3e --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/lib/main.js @@ -0,0 +1,49 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 NINF = require( '@stdlib/constants/float16/ninf' ); + + +// MAIN // + +/** +* Tests if a half-precision floating-point numeric value is negative zero. +* +* @param {number} x - value to test +* @returns {boolean} boolean indicating whether the value is negative zero +* +* @example +* var bool = isNegativeZero( -0.0 ); +* // returns true +* +* @example +* var bool = isNegativeZero( 0.0 ); +* // returns false +*/ +function isNegativeZero( x ) { + return (x === 0.0 && 1.0/x === NINF); +} + + +// EXPORTS // + +module.exports = isNegativeZero; diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/package.json b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/package.json new file mode 100644 index 000000000000..7baea69b28fa --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/package.json @@ -0,0 +1,75 @@ +{ + "name": "@stdlib/number/float16/base/assert/is-negative-zero", + "version": "0.0.0", + "description": "Test if a half-precision floating-point numeric value is negative zero.", + "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", + "assertion", + "assert", + "utilities", + "utility", + "utils", + "util", + "math", + "mathematics", + "ieee754", + "floating-point", + "float", + "number", + "numeric", + "negative", + "zero", + "0", + "is", + "type", + "check" + ], + "__stdlib__": {} +} diff --git a/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/test/test.js b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/test/test.js new file mode 100644 index 000000000000..bbd1d5c3cecb --- /dev/null +++ b/lib/node_modules/@stdlib/number/float16/base/assert/is-negative-zero/test/test.js @@ -0,0 +1,67 @@ +/** +* @license Apache-2.0 +* +* Copyright (c) 2026 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 isNegativeZero = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof isNegativeZero, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns `true` if provided `-0`', function test( t ) { + t.strictEqual( isNegativeZero( -0.0 ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if provided `+0`', function test( t ) { + t.strictEqual( isNegativeZero( +0.0 ), false, 'returns expected value' ); + t.end(); +}); + +tape( 'the function returns `false` if not provided `-0`', function test( t ) { + var values; + var i; + + values = [ + '5', + 5.0, + -1.0, + NaN, + true, + false, + null, + void 0, + [], + {}, + function noop() {} + ]; + + for ( i = 0; i < values.length; i++ ) { + t.strictEqual( isNegativeZero( values[i] ), false, 'returns expected value if provided ' + values[ i ] ); + } + t.end(); +});