diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/README.md b/lib/node_modules/@stdlib/number/int64/base/get-low-word/README.md new file mode 100644 index 000000000000..63c1ea29b4de --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/README.md @@ -0,0 +1,118 @@ + + +# Low Word + +> Return a 32-bit unsigned integer corresponding to the low 32-bit word of a [64-bit signed integer][@stdlib/number/int64/ctor]. + +
+ +## Usage + +```javascript +var getLowWord = require( '@stdlib/number/int64/base/get-low-word' ); +``` + +#### getLowWord( a ) + +Returns a 32-bit unsigned integer corresponding to the low 32-bit word of a [64-bit signed integer][@stdlib/number/int64/ctor]. + +```javascript +var Int64 = require( '@stdlib/number/int64/ctor' ); + +var a = new Int64( 4294967296 ); +var w = getLowWord( a ); +// returns 0 +``` + +For negative values, the function returns the low word of the two's complement representation. + +```javascript +var Int64 = require( '@stdlib/number/int64/ctor' ); + +var a = new Int64( -1 ); +var w = getLowWord( a ); +// returns 4294967295 +``` + +
+ + + +
+ +## Examples + + + +```javascript +var Int64 = require( '@stdlib/number/int64/ctor' ); +var getLowWord = require( '@stdlib/number/int64/base/get-low-word' ); + +var a = new Int64( 4294967296 ); +console.log( getLowWord( a ) ); +// => 0 + +a = new Int64( 0xffffffff ); +console.log( getLowWord( a ) ); +// => 4294967295 + +a = new Int64( 0x123400005678 ); +console.log( getLowWord( a ) ); +// => 22136 + +a = new Int64( -1 ); +console.log( getLowWord( a ) ); +// => 4294967295 + +a = new Int64( -1000000000000 ); +console.log( getLowWord( a ) ); +// => 727379968 + +a = Int64.of( 1234, 5678 ); +console.log( getLowWord( a ) ); +// => 5678 +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/int64/base/get-low-word/benchmark/benchmark.js new file mode 100644 index 000000000000..e667d68aa9c7 --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/benchmark/benchmark.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 isnan = require( '@stdlib/assert/is-nan' ).isPrimitive; +var bench = require( '@stdlib/bench' ); +var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' ); +var MIN_SAFE_INTEGER = require( '@stdlib/constants/float64/min-safe-integer' ); +var Int64 = require( '@stdlib/number/int64/ctor' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); +var pkg = require( './../package.json' ).name; +var getLowWord = require( './../lib' ); + + +// VARIABLES // + +var rand = discreteUniform.factory( MIN_SAFE_INTEGER, MAX_SAFE_INTEGER ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var N; + var a; + var i; + var w; + + N = 100; + values = []; + for ( i = 0; i < N; i++ ) { + values.push( new Int64( rand() ) ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + a = values[ i % N ]; + w = getLowWord( a ); + if ( isnan( w ) ) { + b.fail( 'should not return NaN' ); + } + } + b.toc(); + if ( isnan( w ) ) { + b.fail( 'should not return NaN' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/repl.txt b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/repl.txt new file mode 100644 index 000000000000..2239886e5b6d --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/repl.txt @@ -0,0 +1,29 @@ + +{{alias}}( a ) + Returns a 32-bit unsigned integer corresponding to the low 32-bit word of a + 64-bit signed integer. + + Parameters + ---------- + a: Int64 + Input value. + + Returns + ------- + out: integer + Lower order word (32-bit unsigned integer). + + Examples + -------- + > var a = new {{alias:@stdlib/number/int64/ctor}}( 4294967296 ) + [ 4294967296n ] + > var w = {{alias}}( a ) + 0 + > a = new {{alias:@stdlib/number/int64/ctor}}( -1 ) + [ -1n ] + > w = {{alias}}( a ) + 4294967295 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/index.d.ts new file mode 100644 index 000000000000..0c8cb8b7235b --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/index.d.ts @@ -0,0 +1,50 @@ +/* +* @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 + +/// + +import { Int64 } from '@stdlib/types/number'; + +/** +* Returns a 32-bit unsigned integer corresponding to the low 32-bit word of a 64-bit signed integer. +* +* @param a - input value +* @returns lower order word (32-bit unsigned integer) +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* +* var a = new Int64( 4294967296 ); +* var w = getLowWord( a ); +* // returns 0 +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* +* var a = new Int64( -1 ); +* var w = getLowWord( a ); +* // returns 4294967295 +*/ +declare function getLowWord( a: Int64 ): number; + + +// EXPORTS // + +export = getLowWord; diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/test.ts b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/test.ts new file mode 100644 index 000000000000..dc17978dca8e --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/docs/types/test.ts @@ -0,0 +1,47 @@ +/* +* @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 Int64 = require( '@stdlib/number/int64/ctor' ); +import getLowWord = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + const a = new Int64( 5 ); + getLowWord( a ); // $ExpectType number +} + +// The compiler throws an error if the function is provided an argument that is not a 64-bit signed integer... +{ + getLowWord( 5 ); // $ExpectError + getLowWord( '5' ); // $ExpectError + getLowWord( true ); // $ExpectError + getLowWord( false ); // $ExpectError + getLowWord( [] ); // $ExpectError + getLowWord( {} ); // $ExpectError + getLowWord( ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const a = new Int64( 5 ); + getLowWord(); // $ExpectError + getLowWord( a, a ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/examples/index.js b/lib/node_modules/@stdlib/number/int64/base/get-low-word/examples/index.js new file mode 100644 index 000000000000..1904de15deb6 --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/examples/index.js @@ -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. +*/ + +'use strict'; + +var Int64 = require( '@stdlib/number/int64/ctor' ); +var getLowWord = require( './../lib' ); + +var a = new Int64( 4294967296 ); +console.log( getLowWord( a ) ); +// => 0 + +a = new Int64( 0xffffffff ); +console.log( getLowWord( a ) ); +// => 4294967295 + +a = new Int64( 0x123400005678 ); +console.log( getLowWord( a ) ); +// => 22136 + +a = new Int64( -1 ); +console.log( getLowWord( a ) ); +// => 4294967295 + +a = new Int64( -1000000000000 ); +console.log( getLowWord( a ) ); +// => 727379968 + +a = Int64.of( 1234, 5678 ); +console.log( getLowWord( a ) ); +// => 5678 diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/index.js b/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/index.js new file mode 100644 index 000000000000..3fd1014d4819 --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/index.js @@ -0,0 +1,50 @@ +/** +* @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'; + +/** +* Return a 32-bit unsigned integer corresponding to the low 32-bit word of a 64-bit signed integer. +* +* @module @stdlib/number/int64/base/get-low-word +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* var getLowWord = require( '@stdlib/number/int64/base/get-low-word' ); +* +* var a = new Int64( 4294967296 ); +* var w = getLowWord( a ); +* // returns 0 +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* var getLowWord = require( '@stdlib/number/int64/base/get-low-word' ); +* +* var a = new Int64( -1 ); +* var w = getLowWord( a ); +* // returns 4294967295 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/main.js b/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/main.js new file mode 100644 index 000000000000..1bbcc4c27b57 --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/lib/main.js @@ -0,0 +1,50 @@ +/** +* @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'; + +// MAIN // + +/** +* Returns a 32-bit unsigned integer corresponding to the low 32-bit word of a 64-bit signed integer. +* +* @param {Int64} a - input value +* @returns {uinteger32} lower order word +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* +* var a = new Int64( 4294967296 ); +* var w = getLowWord( a ); +* // returns 0 +* +* @example +* var Int64 = require( '@stdlib/number/int64/ctor' ); +* +* var a = new Int64( -1 ); +* var w = getLowWord( a ); +* // returns 4294967295 +*/ +function getLowWord( a ) { + return a.lo; +} + + +// EXPORTS // + +module.exports = getLowWord; diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/package.json b/lib/node_modules/@stdlib/number/int64/base/get-low-word/package.json new file mode 100644 index 000000000000..6668d674c21c --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/number/int64/base/get-low-word", + "version": "0.0.0", + "description": "Return a 32-bit unsigned integer corresponding to the low 32-bit word of a 64-bit signed integer.", + "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", + "stdtypes", + "base", + "utilities", + "utility", + "utils", + "util", + "types", + "type", + "int64", + "signed", + "64-bit", + "integer", + "int", + "get", + "low", + "word" + ] +} diff --git a/lib/node_modules/@stdlib/number/int64/base/get-low-word/test/test.js b/lib/node_modules/@stdlib/number/int64/base/get-low-word/test/test.js new file mode 100644 index 000000000000..08a2059c9b3d --- /dev/null +++ b/lib/node_modules/@stdlib/number/int64/base/get-low-word/test/test.js @@ -0,0 +1,137 @@ +/** +* @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 isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; +var MIN_SAFE_INTEGER = require( '@stdlib/constants/float64/min-safe-integer' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var Int64 = require( '@stdlib/number/int64/ctor' ); +var getLowWord = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof getLowWord, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns an integer', function test( t ) { + var a; + var w; + + a = new Int64( 4294967296 ); + w = getLowWord( a ); + + t.ok( isInteger( w ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function returns the low 32-bit word of a positive 64-bit signed integer', function test( t ) { + var values; + var a; + var v; + var w; + var i; + + values = [ + 0, + 1, + 2, + 3, + 4, + 5, + 10, + 99, + 100, + 999, + 1000, + 999999, + 1000000, + 999999999, + 1000000000, + UINT32_MAX + ]; + + for ( i = 0; i < values.length; i++ ) { + v = values[ i ]; + a = Int64.of( 0, v ); + w = getLowWord( a ); + t.strictEqual( w, v, 'returns expected value' ); + } + t.end(); +}); + +tape( 'the function returns the low 32-bit word of a negative 64-bit signed integer', function test( t ) { + var expected; + var values; + var a; + var w; + var i; + + values = [ + -0, + -1, + -2, + -3, + -4, + -5, + -10, + -99, + -100, + -999, + -1000, + -999999, + -1000000, + -999999999, + -1000000000, + MIN_SAFE_INTEGER + ]; + + expected = [ + 0, + 4294967295, + 4294967294, + 4294967293, + 4294967292, + 4294967291, + 4294967286, + 4294967197, + 4294967196, + 4294966297, + 4294966296, + 4293967297, + 4293967296, + 3294967297, + 3294967296, + 1 + ]; + + for ( i = 0; i < values.length; i++ ) { + a = new Int64( values[ i ] ); + w = getLowWord( a ); + t.strictEqual( w, expected[ i ], 'returns expected value' ); + } + t.end(); +});