diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/README.md new file mode 100644 index 000000000000..915616054698 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/README.md @@ -0,0 +1,112 @@ + + +# setLowWord + +> Set the low 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. + +
+ +## Usage + +```javascript +var setLowWord = require( '@stdlib/number/uint64/base/set-low-word' ); +``` + +#### setLowWord( x, low ) + +Sets the low 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. + +```javascript +var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var a = new Uint64( 4294967296 ); +// returns [ 4294967296n ] + +var b = setLowWord( a, 2 ); +// returns [ 4294967298n ] + +var w = getLowWord( b ); +// returns 2 +``` + +
+ + + +
+ +## Notes + +- The function returns a new [64-bit unsigned integer][@stdlib/number/uint64/ctor] instance without modifying the input value. + +
+ + + +
+ +## Examples + + + +```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var setLowWord = require( '@stdlib/number/uint64/base/set-low-word' ); + +var a = new Uint64( 4294967296 ); +// returns + +var words = discreteUniform( 100, 0, UINT32_MAX, { + 'dtype': 'uint32' +}); + +logEachMap( 'setLowWord(%s, %s) = %s', a, words, setLowWord ); +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/benchmark/benchmark.js new file mode 100644 index 000000000000..98329080dc7a --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/benchmark/benchmark.js @@ -0,0 +1,60 @@ +/** +* @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 UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var pkg = require( './../package.json' ).name; +var setLowWord = require( './../lib' ); + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var N; + var a; + var i; + var z; + + N = 100; + values = discreteUniform( N, 0, UINT32_MAX, { + 'dtype': 'uint32' + }); + + a = new Uint64( 0 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + z = setLowWord( a, values[ i % N ] ); + if ( typeof z !== 'object' ) { + b.fail( 'should return a Uint64 instance' ); + } + } + b.toc(); + if ( !( z instanceof Uint64 ) ) { + b.fail( 'should return a Uint64 instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/repl.txt b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/repl.txt new file mode 100644 index 000000000000..6910360515b2 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/repl.txt @@ -0,0 +1,32 @@ + +{{alias}}( a, low ) + Sets the low 32-bit word of a 64-bit unsigned integer. + + The function returns a new Uint64 instance without modifying the input + value. + + Parameters + ---------- + a: Uint64 + 64-bit unsigned integer. + + low: integer + 32-bit unsigned integer to replace the low 32-bit word. + + Returns + ------- + out: Uint64 + 64-bit unsigned integer. + + Examples + -------- + > var a = new {{alias:@stdlib/number/uint64/ctor}}( 4294967296 ) + [ 4294967296n ] + > var b = {{alias}}( a, 2 ) + [ 4294967298n ] + > var w = {{alias:@stdlib/number/uint64/base/get-low-word}}( b ) + 2 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/types/index.d.ts new file mode 100644 index 000000000000..2fa002c45c9d --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-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 { Uint64 } from '@stdlib/types/number'; + +/** +* Sets the low 32-bit word of a 64-bit unsigned integer. +* +* @param a - 64-bit unsigned integer +* @param low - 32-bit unsigned integer to replace the low 32-bit word +* @returns 64-bit unsigned integer +* +* @example +* var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* +* var b = setLowWord( a, 2 ); +* // returns [ 4294967298n ] +* +* var w = getLowWord( b ); +* // returns 2 +*/ +declare function setLowWord( a: Uint64, low: number ): Uint64; + + +// EXPORTS // + +export = setLowWord; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/types/test.ts b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/types/test.ts new file mode 100644 index 000000000000..7591e9b45854 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/docs/types/test.ts @@ -0,0 +1,58 @@ +/* +* @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 Uint64 = require( '@stdlib/number/uint64/ctor' ); +import setLowWord = require( './index' ); + + +// TESTS // + +// The function returns a Uint64 instance... +{ + const a = new Uint64( 5 ); + setLowWord( a, 2 ); // $ExpectType Uint64 +} + +// The compiler throws an error if the function is provided a first argument that is not a Uint64 instance... +{ + setLowWord( 'abc', 2 ); // $ExpectError + setLowWord( true, 2 ); // $ExpectError + setLowWord( false, 2 ); // $ExpectError + setLowWord( [], 2 ); // $ExpectError + setLowWord( {}, 2 ); // $ExpectError + setLowWord( ( x: number ): number => x, 2 ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument that is not a number... +{ + const a = new Uint64( 5 ); + setLowWord( a, 'abc' ); // $ExpectError + setLowWord( a, true ); // $ExpectError + setLowWord( a, false ); // $ExpectError + setLowWord( a, [] ); // $ExpectError + setLowWord( a, {} ); // $ExpectError + setLowWord( a, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + const a = new Uint64( 5 ); + setLowWord(); // $ExpectError + setLowWord( a ); // $ExpectError + setLowWord( a, 2, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/examples/index.js new file mode 100644 index 000000000000..1f9929aa597e --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/examples/index.js @@ -0,0 +1,34 @@ +/** +* @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 discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var setLowWord = require( './../lib' ); + +var a = new Uint64( 4294967296 ); +// returns + +var words = discreteUniform( 100, 0, UINT32_MAX, { + 'dtype': 'uint32' +}); + +logEachMap( 'setLowWord(%s, %s) = %s', a, words, setLowWord ); diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/index.js new file mode 100644 index 000000000000..d2221b737244 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/index.js @@ -0,0 +1,48 @@ +/** +* @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'; + +/** +* Set the low 32-bit word of a 64-bit unsigned integer. +* +* @module @stdlib/number/uint64/base/set-low-word +* +* @example +* var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* var setLowWord = require( '@stdlib/number/uint64/base/set-low-word' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* +* var b = setLowWord( a, 2 ); +* // returns [ 4294967298n ] +* +* var w = getLowWord( b ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/main.js new file mode 100644 index 000000000000..ed42546e6459 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/lib/main.js @@ -0,0 +1,56 @@ +/** +* @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 getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + + +// MAIN // + +/** +* Sets the low 32-bit word of a 64-bit unsigned integer. +* +* @param {Uint64} a - 64-bit unsigned integer +* @param {uinteger32} low - 32-bit unsigned integer to replace the low 32-bit word +* @returns {Uint64} 64-bit unsigned integer +* +* @example +* var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* +* var b = setLowWord( a, 2 ); +* // returns [ 4294967298n ] +* +* var w = getLowWord( b ); +* // returns 2 +*/ +function setLowWord( a, low ) { + return Uint64.of( getHighWord( a ), low ); +} + + +// EXPORTS // + +module.exports = setLowWord; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/package.json b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/package.json new file mode 100644 index 000000000000..6b885cd3ac4a --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/number/uint64/base/set-low-word", + "version": "0.0.0", + "description": "Set the low 32-bit word of a 64-bit unsigned 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", + "uint64", + "unsigned", + "64-bit", + "integer", + "int", + "set", + "low", + "word" + ] +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-low-word/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/test/test.js new file mode 100644 index 000000000000..c159da239100 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-low-word/test/test.js @@ -0,0 +1,83 @@ +/** +* @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 isUint64 = require( '@stdlib/assert/is-uint64' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var setLowWord = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof setLowWord, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function returns a Uint64 instance', function test( t ) { + var a = new Uint64( 0 ); + var b = setLowWord( a, 2 ); + t.ok( isUint64( b ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function sets the low 32-bit word of a 64-bit unsigned integer', function test( t ) { + var values; + var a; + var b; + 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 = new Uint64( 0 ); + w = getHighWord( a ); + b = setLowWord( a, v ); + t.strictEqual( getHighWord( b ), w, 'returns expected value' ); + t.strictEqual( getLowWord( b ), v, 'returns expected value' ); + } + t.end(); +});