diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/README.md b/lib/node_modules/@stdlib/constants/float16/sign-mask/README.md new file mode 100644 index 000000000000..77d3e20998c8 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/README.md @@ -0,0 +1,160 @@ + + +# FLOAT16_SIGN_MASK + +> Mask for the sign bit of a [half-precision floating-point number][ieee754]. + +
+ +## Usage + + + +```javascript +var FLOAT16_SIGN_MASK = require( '@stdlib/constants/float16/sign-mask' ); +``` + +#### FLOAT16_SIGN_MASK + +Mask for the sign bit of a [half-precision floating-point number][ieee754]. + + + +```javascript +// 0x8000 = 32768 => 1 00000 0000000000 +var bool = ( FLOAT16_SIGN_MASK === 0x8000 ); +// returns true +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + + + +```javascript +var toWord = require( '@stdlib/number/float16/base/to-word' ); +var FLOAT16_SIGN_MASK = require( '@stdlib/constants/float16/sign-mask' ); + +var x = -11.5; +var w = toWord( x ); // 1 10010 0111000000 +// returns 51648 + +// Mask off all bits except for the sign bit: +var out = (w & FLOAT16_SIGN_MASK)>>>0; // 1 00000 0000000000 +// returns 32768 + +// Turn off the sign bit and leave other bits unchanged: +out = w & (~FLOAT16_SIGN_MASK); // 0 10010 0111000000 +// returns 18880 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float16/sign_mask.h" +``` + +#### STDLIB_CONSTANT_FLOAT16_SIGN_MASK + +Macro for the mask for the sign bit of a [half-precision floating-point number][ieee754]. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/repl.txt b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/repl.txt new file mode 100644 index 000000000000..4bbb285ce0fd --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/repl.txt @@ -0,0 +1,14 @@ + +{{alias}} + Mask for the sign bit of a half-precision floating-point number. + + Examples + -------- + > {{alias}} + 32768 + > {{alias:@stdlib/number/uint16/base/to-binary-string}}( {{alias}} ) + '1000000000000000' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/index.d.ts new file mode 100644 index 000000000000..71f6785a0550 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/index.d.ts @@ -0,0 +1,33 @@ +/* +* @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 + +/** +* Mask for the sign bit of a half-precision floating-point number. +* +* @example +* var mask = FLOAT16_SIGN_MASK; +* // returns 32768 +*/ +declare const FLOAT16_SIGN_MASK: number; + + +// EXPORTS // + +export = FLOAT16_SIGN_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/test.ts new file mode 100644 index 000000000000..fb7b4f1ded5e --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/docs/types/test.ts @@ -0,0 +1,28 @@ +/* +* @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 FLOAT16_SIGN_MASK = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT16_SIGN_MASK; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/examples/index.js b/lib/node_modules/@stdlib/constants/float16/sign-mask/examples/index.js new file mode 100644 index 000000000000..a1be3e82f76c --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/examples/index.js @@ -0,0 +1,33 @@ +/** +* @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 toWord = require( '@stdlib/number/float16/base/to-word' ); +var toBinaryString = require( '@stdlib/number/uint16/base/to-binary-string' ); +var FLOAT16_SIGN_MASK = require( './../lib' ); + +var x = -11.5; +var w = toWord( x ); +console.log( 'Word: %s', toBinaryString( w ) ); + +var out = (w & FLOAT16_SIGN_MASK)>>>0; +console.log( 'Isolate sign bits: %s', toBinaryString( out ) ); + +out = w & (~FLOAT16_SIGN_MASK); +console.log( 'Turn off sign bits: %s', toBinaryString( out ) ); diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/include/stdlib/constants/float16/sign_mask.h b/lib/node_modules/@stdlib/constants/float16/sign-mask/include/stdlib/constants/float16/sign_mask.h new file mode 100644 index 000000000000..870f74d5cfc2 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/include/stdlib/constants/float16/sign_mask.h @@ -0,0 +1,27 @@ +/** +* @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. +*/ + +#ifndef STDLIB_CONSTANTS_FLOAT16_SIGN_MASK_H +#define STDLIB_CONSTANTS_FLOAT16_SIGN_MASK_H + +/** +* Macro for the mask for the sign bit of a half-precision floating-point number. +*/ +#define STDLIB_CONSTANT_FLOAT16_SIGN_MASK 0x8000 + +#endif // !STDLIB_CONSTANTS_FLOAT16_SIGN_MASK_H diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/lib/index.js b/lib/node_modules/@stdlib/constants/float16/sign-mask/lib/index.js new file mode 100644 index 000000000000..509063b7f983 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/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'; + +/** +* Mask for the sign bit of a half-precision floating-point number. +* +* @module @stdlib/constants/float16/sign-mask +* @type {uinteger16} +* +* @example +* var FLOAT16_SIGN_MASK = require( '@stdlib/constants/float16/sign-mask' ); +* // returns 32768 +*/ + + +// MAIN // + +/** +* Mask for the sign bit of a half-precision floating-point number. +* +* ## Notes +* +* The mask for the sign bit of a half-precision floating-point number is an unsigned 16-bit integer with the value \\( 32768 \\), which corresponds to the bit sequence +* +* ```binarystring +* 1 00000 0000000000 +* ``` +* +* @constant +* @type {uinteger16} +* @default 0x8000 +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT16_SIGN_MASK = 0x8000>>>0; + + +// EXPORTS // + +module.exports = FLOAT16_SIGN_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/manifest.json b/lib/node_modules/@stdlib/constants/float16/sign-mask/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/manifest.json @@ -0,0 +1,36 @@ +{ + "options": {}, + "fields": [ + { + "field": "src", + "resolve": true, + "relative": true + }, + { + "field": "include", + "resolve": true, + "relative": true + }, + { + "field": "libraries", + "resolve": false, + "relative": false + }, + { + "field": "libpath", + "resolve": true, + "relative": false + } + ], + "confs": [ + { + "src": [], + "include": [ + "./include" + ], + "libraries": [], + "libpath": [], + "dependencies": [] + } + ] +} diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/package.json b/lib/node_modules/@stdlib/constants/float16/sign-mask/package.json new file mode 100644 index 000000000000..3bb3315a0763 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/constants/float16/sign-mask", + "version": "0.0.0", + "description": "Mask for the sign bit of a half-precision floating-point number.", + "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": { + "doc": "./docs", + "example": "./examples", + "include": "./include", + "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", + "constant", + "const", + "mathematics", + "math", + "float", + "float16", + "16bit", + "floating-point", + "ieee754", + "mask", + "sign", + "bits", + "word" + ] +} diff --git a/lib/node_modules/@stdlib/constants/float16/sign-mask/test/test.js b/lib/node_modules/@stdlib/constants/float16/sign-mask/test/test.js new file mode 100644 index 000000000000..40fab45f5d2a --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/sign-mask/test/test.js @@ -0,0 +1,52 @@ +/** +* @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 toBinaryString = require( '@stdlib/number/uint16/base/to-binary-string' ); +var toWord = require( '@stdlib/number/float16/base/to-word' ); +var FLOAT16_SIGN_MASK = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT16_SIGN_MASK, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value can be used to mask off all bits except for the sign bit', function test( t ) { + var expected; + var actual; + var w; + var x; + + x = -33.8; + w = toWord( x ); // 53306 => 1 10100 0000111010 + + actual = (w & FLOAT16_SIGN_MASK)>>>0; // 32768 => 1 00000 0000000000 + expected = '1000000000000000'; + + t.strictEqual( toBinaryString( actual ), expected ); + + t.end(); +});