diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/README.md b/lib/node_modules/@stdlib/constants/float16/abs-mask/README.md new file mode 100644 index 000000000000..5fda51262382 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/README.md @@ -0,0 +1,156 @@ + + +# FLOAT16_ABS_MASK + +> Mask for excluding the sign bit of a [half-precision floating-point number][ieee754]. + +
+ +## Usage + +```javascript +var FLOAT16_ABS_MASK = require( '@stdlib/constants/float16/abs-mask' ); +``` + +#### FLOAT16_ABS_MASK + +Mask for excluding the sign bit of a [half-precision floating-point number][ieee754]. + +```javascript +// 0x7fff = 32767 => 0 11111 1111111111 +var bool = ( FLOAT16_ABS_MASK === 0x7fff ); +// returns true +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var toWord = require( '@stdlib/number/float16/base/to-word' ); +var fromWord = require( '@stdlib/number/float16/base/from-word' ); +var toBinaryString = require( '@stdlib/number/uint32/base/to-binary-string' ); +var FLOAT16_ABS_MASK = require( '@stdlib/constants/float16/abs-mask' ); + +var x = -11.5; +var w = toWord( x ); // 1 10010 0111000000 +// returns 51648 + +// Turn off the sign bit and leave other bits unchanged: +var out = w & FLOAT16_ABS_MASK; // 0 10010 0111000000 +// returns 18880 + +// Generate a new value: +out = fromWord( out ); +// returns 11.5 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float16/abs_mask.h" +``` + +#### STDLIB_CONSTANT_FLOAT16_ABS_MASK + +Macro for the mask for excluding the sign bit of a [half-precision floating-point number][ieee754]. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/repl.txt b/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/repl.txt new file mode 100644 index 000000000000..fe6213b80f2b --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/repl.txt @@ -0,0 +1,14 @@ + +{{alias}} + Mask for excluding the sign bit of a half-precision floating-point number. + + Examples + -------- + > {{alias}} + 32767 + > {{alias:@stdlib/number/uint16/base/to-binary-string}}( {{alias}} ) + '0111111111111111' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/types/index.d.ts new file mode 100644 index 000000000000..b9c456f40ff1 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-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 excluding the sign bit of a half-precision floating-point number. +* +* @example +* var mask = FLOAT16_ABS_MASK; +* // returns 32767 +*/ +declare const FLOAT16_ABS_MASK: number; + + +// EXPORTS // + +export = FLOAT16_ABS_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float16/abs-mask/docs/types/test.ts new file mode 100644 index 000000000000..18d6bcab7d8f --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-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_ABS_MASK = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT16_ABS_MASK; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/examples/index.js b/lib/node_modules/@stdlib/constants/float16/abs-mask/examples/index.js new file mode 100644 index 000000000000..20524c975681 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 fromWord = require( '@stdlib/number/float16/base/from-word' ); +var toBinaryString = require( '@stdlib/number/uint32/base/to-binary-string' ); +var FLOAT16_ABS_MASK = require( './../lib' ); + +var x = -11.5; +var w = toWord( x ); +console.log( 'Word: %s', toBinaryString( w ) ); + +var out = w & FLOAT16_ABS_MASK; +console.log( 'Turn off sign bits: %s', toBinaryString( out ) ); + +out = fromWord( out ); +console.log( 'Absolute value: %d', out ); diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/include/stdlib/constants/float16/abs_mask.h b/lib/node_modules/@stdlib/constants/float16/abs-mask/include/stdlib/constants/float16/abs_mask.h new file mode 100644 index 000000000000..c904096017c7 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/include/stdlib/constants/float16/abs_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_ABS_MASK_H +#define STDLIB_CONSTANTS_FLOAT16_ABS_MASK_H + +/** +* Macro for the mask for excluding the sign bit of a half-precision floating-point number. +*/ +#define STDLIB_CONSTANT_FLOAT16_ABS_MASK 0x7fff + +#endif // !STDLIB_CONSTANTS_FLOAT16_ABS_MASK_H diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/lib/index.js b/lib/node_modules/@stdlib/constants/float16/abs-mask/lib/index.js new file mode 100644 index 000000000000..c395ae8a3483 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-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 excluding the sign bit of a half-precision floating-point number. +* +* @module @stdlib/constants/float16/abs-mask +* @type {uinteger16} +* +* @example +* var FLOAT16_ABS_MASK = require( '@stdlib/constants/float16/abs-mask' ); +* // returns 32767 +*/ + + +// MAIN // + +/** +* Mask for excluding the sign bit of a half-precision floating-point number. +* +* ## Notes +* +* The mask for excluding the sign bit of a half-precision floating-point number is an unsigned 16-bit integer with the value \\( 32767 \\), which corresponds to the bit sequence +* +* ```binarystring +* 0 11111 1111111111 +* ``` +* +* @constant +* @type {uinteger16} +* @default 0x7fff +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT16_ABS_MASK = 0x7fff>>>0; + + +// EXPORTS // + +module.exports = FLOAT16_ABS_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/abs-mask/manifest.json b/lib/node_modules/@stdlib/constants/float16/abs-mask/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-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/abs-mask/package.json b/lib/node_modules/@stdlib/constants/float16/abs-mask/package.json new file mode 100644 index 000000000000..b599bd4f1fb6 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/constants/float16/abs-mask", + "version": "0.0.0", + "description": "Mask for excluding 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/abs-mask/test/test.js b/lib/node_modules/@stdlib/constants/float16/abs-mask/test/test.js new file mode 100644 index 000000000000..e3917552433a --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/abs-mask/test/test.js @@ -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. +*/ + +'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_ABS_MASK = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT16_ABS_MASK, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value equals 32767', function test( t ) { + t.strictEqual( FLOAT16_ABS_MASK, 32767, 'returns expected value' ); + t.strictEqual( FLOAT16_ABS_MASK, 0x7fff, 'returns expected value' ); + t.end(); +}); + +tape( 'the exported value can be used to mask off the sign bit', function test( t ) { + var expected; + var actual; + var hi; + var x; + + x = -1.0; + hi = toWord( x ); // 1 01111 0000000000 + + actual = hi & FLOAT16_ABS_MASK; + expected = '0011110000000000'; + + t.strictEqual( toBinaryString( actual ), expected ); + + t.end(); +});