diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/README.md b/lib/node_modules/@stdlib/constants/float16/exponent-mask/README.md new file mode 100644 index 000000000000..61eba53cd286 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-mask/README.md @@ -0,0 +1,158 @@ + + +# FLOAT16_EXPONENT_MASK + +> Mask for the exponent of a [half-precision floating-point number][ieee754]. + +
+ +## Usage + + + +```javascript +var FLOAT16_EXPONENT_MASK = require( '@stdlib/constants/float16/exponent-mask' ); +``` + +#### FLOAT16_EXPONENT_MASK + +Mask for the exponent of a [half-precision floating-point number][ieee754]. + + + +```javascript +// 0x7c00 = 31744 => 0 11111 0000000000 +var bool = ( FLOAT16_EXPONENT_MASK === 0x7c00 ); +// returns true +``` + +
+ + + +
+ +
+ + + +
+ +## Examples + + + +```javascript +var toWord = require( '@stdlib/number/float16/base/to-word' ); +var FLOAT16_EXPONENT_MASK = require( '@stdlib/constants/float16/exponent-mask' ); + +var x = 11.5; +var w = toWord( x ); // 0 10010 0111000000 +// returns 18880 + +// Mask off all bits except for the exponent bits: +var out = w & FLOAT16_EXPONENT_MASK; // 0 10010 0000000000 +// returns 18432 + +// Mask on the exponent bits and leave other bits unchanged: +out = w | FLOAT16_EXPONENT_MASK; // 0 11111 0111000000 +// returns 32192 +``` + +
+ + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/constants/float16/exponent_mask.h" +``` + +#### STDLIB_CONSTANT_FLOAT16_EXPONENT_MASK + +Macro for the mask for the exponent of a [half-precision floating-point number][ieee754]. + +
+ + + + + +
+ +
+ + + + + +
+ +
+ + + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/repl.txt b/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/repl.txt new file mode 100644 index 000000000000..bc5959ef93c4 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/repl.txt @@ -0,0 +1,14 @@ + +{{alias}} + Mask for the exponent of a half-precision floating-point number. + + Examples + -------- + > {{alias}} + 31744 + > {{alias:@stdlib/number/uint16/base/to-binary-string}}( {{alias}} ) + '0111110000000000' + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/types/index.d.ts b/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/types/index.d.ts new file mode 100644 index 000000000000..dbc2abded141 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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 exponent of a half-precision floating-point number. +* +* @example +* var mask = FLOAT16_EXPONENT_MASK; +* // returns 31744 +*/ +declare const FLOAT16_EXPONENT_MASK: number; + + +// EXPORTS // + +export = FLOAT16_EXPONENT_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/types/test.ts b/lib/node_modules/@stdlib/constants/float16/exponent-mask/docs/types/test.ts new file mode 100644 index 000000000000..3cea93af4f85 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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_EXPONENT_MASK = require( './index' ); + + +// TESTS // + +// The export is a number... +{ + // eslint-disable-next-line @typescript-eslint/no-unused-expressions + FLOAT16_EXPONENT_MASK; // $ExpectType number +} diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/examples/index.js b/lib/node_modules/@stdlib/constants/float16/exponent-mask/examples/index.js new file mode 100644 index 000000000000..b968ddeb5b3e --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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_EXPONENT_MASK = require( './../lib' ); + +var x = 11.5; +var w = toWord( x ); +console.log( 'Word: %s', toBinaryString( w ) ); + +var out = w & FLOAT16_EXPONENT_MASK; +console.log( 'Isolate exponent bits: %s', toBinaryString( out ) ); + +out = w | FLOAT16_EXPONENT_MASK; +console.log( 'Turn on exponent bits: %s', toBinaryString( out ) ); diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/include/stdlib/constants/float16/exponent_mask.h b/lib/node_modules/@stdlib/constants/float16/exponent-mask/include/stdlib/constants/float16/exponent_mask.h new file mode 100644 index 000000000000..3cfe5c7eb626 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-mask/include/stdlib/constants/float16/exponent_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_EXPONENT_MASK_H +#define STDLIB_CONSTANTS_FLOAT16_EXPONENT_MASK_H + +/** +* Macro for the mask for the exponent of a half-precision floating-point number. +*/ +#define STDLIB_CONSTANT_FLOAT16_EXPONENT_MASK 0x7c00 + +#endif // !STDLIB_CONSTANTS_FLOAT16_EXPONENT_MASK_H diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/lib/index.js b/lib/node_modules/@stdlib/constants/float16/exponent-mask/lib/index.js new file mode 100644 index 000000000000..12e5715fa883 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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 exponent of a half-precision floating-point number. +* +* @module @stdlib/constants/float16/exponent-mask +* @type {uinteger16} +* +* @example +* var FLOAT16_EXPONENT_MASK = require( '@stdlib/constants/float16/exponent-mask' ); +* // returns 31744 +*/ + + +// MAIN // + +/** +* Mask for the exponent of a half-precision floating-point number. +* +* ## Notes +* +* The mask for the exponent of a half-precision floating-point number is an unsigned 16-bit integer with the value \\( 31744 \\), which corresponds to the bit sequence +* +* ```binarystring +* 0 11111 0000000000 +* ``` +* +* @constant +* @type {uinteger16} +* @default 0x7c00 +* @see [IEEE 754]{@link https://en.wikipedia.org/wiki/IEEE_754-1985} +*/ +var FLOAT16_EXPONENT_MASK = 0x7c00; + + +// EXPORTS // + +module.exports = FLOAT16_EXPONENT_MASK; diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/manifest.json b/lib/node_modules/@stdlib/constants/float16/exponent-mask/manifest.json new file mode 100644 index 000000000000..844d692f6439 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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/exponent-mask/package.json b/lib/node_modules/@stdlib/constants/float16/exponent-mask/package.json new file mode 100644 index 000000000000..68c817dae301 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-mask/package.json @@ -0,0 +1,68 @@ +{ + "name": "@stdlib/constants/float16/exponent-mask", + "version": "0.0.0", + "description": "Mask for the exponent 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", + "exponent", + "bits", + "word" + ] +} diff --git a/lib/node_modules/@stdlib/constants/float16/exponent-mask/test/test.js b/lib/node_modules/@stdlib/constants/float16/exponent-mask/test/test.js new file mode 100644 index 000000000000..3d35a06d81c9 --- /dev/null +++ b/lib/node_modules/@stdlib/constants/float16/exponent-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_EXPONENT_MASK = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a number', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof FLOAT16_EXPONENT_MASK, 'number', 'main export is a number' ); + t.end(); +}); + +tape( 'the exported value can be used to mask off all bits except for the exponent bits', function test( t ) { + var expected; + var actual; + var w; + var x; + + x = 33.8; + w = toWord( x ); // 20538 => 0 10100 0000111010 + + actual = w & FLOAT16_EXPONENT_MASK; // 29952 => 0 10100 0000000000 + expected = '0101000000000000'; + + t.strictEqual( toBinaryString( actual ), expected ); + + t.end(); +});