From 8dd09905e95cbff6adbdc4b7d2c4dc85c089454d Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Sun, 19 Jul 2026 00:03:40 +0600 Subject: [PATCH 01/11] feat: add `number/uint64/base/set-high-word` --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown_pkg_readmes status: passed - task: lint_markdown_docs status: na - task: lint_markdown status: na - task: lint_package_json status: passed - task: lint_repl_help status: passed - task: lint_javascript_src status: passed - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: passed - task: lint_javascript_benchmarks status: passed - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: passed - task: lint_license_headers status: passed --- --- .../uint64/base/set-high-word/README.md | 96 +++++++++++++++++++ .../base/set-high-word/benchmark/benchmark.js | 60 ++++++++++++ .../uint64/base/set-high-word/docs/repl.txt | 31 ++++++ .../base/set-high-word/docs/types/index.d.ts | 48 ++++++++++ .../base/set-high-word/docs/types/test.ts | 58 +++++++++++ .../base/set-high-word/examples/index.js | 28 ++++++ .../uint64/base/set-high-word/lib/index.js | 46 +++++++++ .../uint64/base/set-high-word/lib/main.js | 53 ++++++++++ .../uint64/base/set-high-word/package.json | 70 ++++++++++++++ .../uint64/base/set-high-word/test/test.js | 81 ++++++++++++++++ 10 files changed, 571 insertions(+) create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/package.json create mode 100644 lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md new file mode 100644 index 000000000000..ce522a05ffb4 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -0,0 +1,96 @@ + + +# Set High Word + +> Set the high 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. + +
+ +## Usage + +```javascript +var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); +``` + +#### setHighWord( x, high ) + +Sets the high 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. + +The function returns a new `Uint64` instance without modifying the input. + +```javascript +var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var a = new Uint64( 4294967296 ); +// returns [ 4294967296n ] +var b = setHighWord( a, 2 ); +// returns [ 8589934592n ] +var w = getHighWord( b ); +// returns 2 +``` + +
+ + + +
+ +## Examples + + + +```javascript +var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); + +var a = new Uint64( 4294967296 ); +var b = setHighWord( a, 2 ); +console.log( 'value: %s, high word: %s', b, getHighWord( b ) ); +// => 'value: 8589934592, high word: 2' +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/benchmark/benchmark.js new file mode 100644 index 000000000000..e0d69a00cc08 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-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 setHighWord = 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 = setHighWord( 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-high-word/docs/repl.txt b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/repl.txt new file mode 100644 index 000000000000..bb163a599b20 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/repl.txt @@ -0,0 +1,31 @@ + +{{alias}}( a, high ) + Sets the high 32-bit word of a 64-bit unsigned integer. + + The function returns a new Uint64 instance without modifying the input. + + Parameters + ---------- + a: Uint64 + 64-bit unsigned integer. + + high: integer + 32-bit unsigned integer to replace the high 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 ) + [ 8589934592n ] + > var w = {{alias:@stdlib/number/uint64/base/get-high-word}}( b ) + 2 + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts new file mode 100644 index 000000000000..50ceec4c7928 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts @@ -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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Uint64 } from '@stdlib/types/number'; + +/** +* Sets the high 32-bit word of a 64-bit unsigned integer. +* +* @param a - 64-bit unsigned integer +* @param high - 32-bit unsigned integer to replace the high 32-bit word +* @returns 64-bit unsigned integer +* +* @example +* var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* var b = setHighWord( a, 2 ); +* // returns [ 8589934592n ] +* var w = getHighWord( b ); +* // returns 2 +*/ +declare function setHighWord( a: Uint64, high: number ): Uint64; + + +// EXPORTS // + +export = setHighWord; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/test.ts b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/test.ts new file mode 100644 index 000000000000..43f0c4e1e172 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-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 setHighWord = require( './index' ); + + +// TESTS // + +// The function returns a Uint64 instance... +{ + const a = new Uint64( 5 ); + setHighWord( a, 2 ); // $ExpectType Uint64 +} + +// The compiler throws an error if the function is provided a first argument that is not a Uint64 instance... +{ + setHighWord( 'abc', 2 ); // $ExpectError + setHighWord( true, 2 ); // $ExpectError + setHighWord( false, 2 ); // $ExpectError + setHighWord( [], 2 ); // $ExpectError + setHighWord( {}, 2 ); // $ExpectError + setHighWord( ( 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 ); + setHighWord( a, 'abc' ); // $ExpectError + setHighWord( a, true ); // $ExpectError + setHighWord( a, false ); // $ExpectError + setHighWord( a, [] ); // $ExpectError + setHighWord( a, {} ); // $ExpectError + setHighWord( 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 ); + setHighWord(); // $ExpectError + setHighWord( a ); // $ExpectError + setHighWord( a, 2, 0 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js new file mode 100644 index 000000000000..671256ae2b99 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js @@ -0,0 +1,28 @@ +/** +* @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 getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var setHighWord = require( './../lib' ); + +var a = new Uint64( 4294967296 ); +var b = setHighWord( a, 2 ); +console.log( 'value: %s, high word: %s', b, getHighWord( b ) ); +// => 'value: 8589934592, high word: 2' diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js new file mode 100644 index 000000000000..8569015072bc --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/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'; + +/** +* Set the high 32-bit word of a 64-bit unsigned integer. +* +* @module @stdlib/number/uint64/base/set-high-word +* +* @example +* var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* var b = setHighWord( a, 2 ); +* // returns [ 8589934592n ] +* var w = getHighWord( b ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js new file mode 100644 index 000000000000..7f71901abf5c --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js @@ -0,0 +1,53 @@ +/** +* @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 Uint64 = require( '@stdlib/number/uint64/ctor' ); + + +// MAIN // + +/** +* Sets the high 32-bit word of a 64-bit unsigned integer. +* +* @param {Uint64} a - 64-bit unsigned integer +* @param {uinteger32} high - 32-bit unsigned integer to replace the high 32-bit word +* @returns {Uint64} 64-bit unsigned integer +* +* @example +* var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 4294967296 ); +* // returns [ 4294967296n ] +* var b = setHighWord( a, 2 ); +* // returns [ 8589934592n ] +* var w = getHighWord( b ); +* // returns 2 +*/ +function setHighWord( a, high ) { + return Uint64.of( high, a.lo ); +} + + +// EXPORTS // + +module.exports = setHighWord; diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/package.json b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/package.json new file mode 100644 index 000000000000..5ccde4318d69 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/package.json @@ -0,0 +1,70 @@ +{ + "name": "@stdlib/number/uint64/base/set-high-word", + "version": "0.0.0", + "description": "Set the high 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", + "high", + "word" + ] +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js new file mode 100644 index 000000000000..c176eeff9ba0 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js @@ -0,0 +1,81 @@ +/** +* @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 Uint64 = require( '@stdlib/number/uint64/ctor' ); +var setHighWord = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof setHighWord, '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 = setHighWord( a, 2 ); + t.ok( isUint64( b ), 'returns expected value' ); + t.end(); +}); + +tape( 'the function sets the high 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 ); + b = setHighWord( a, v ); + w = getHighWord( b ); + t.strictEqual( w, v, 'returns expected value' ); + } + t.end(); +}); From fa93ccc89e1e64ddb5165b081679700f271c307c Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 14:57:50 -0700 Subject: [PATCH 02/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 2 ++ .../number/uint64/base/set-high-word/docs/types/index.d.ts | 2 ++ .../@stdlib/number/uint64/base/set-high-word/lib/index.js | 2 ++ .../@stdlib/number/uint64/base/set-high-word/lib/main.js | 2 ++ 4 files changed, 8 insertions(+) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index ce522a05ffb4..094a1600484f 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -42,8 +42,10 @@ var Uint64 = require( '@stdlib/number/uint64/ctor' ); var a = new Uint64( 4294967296 ); // returns [ 4294967296n ] + var b = setHighWord( a, 2 ); // returns [ 8589934592n ] + var w = getHighWord( b ); // returns 2 ``` diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts index 50ceec4c7928..f29d35233d84 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/docs/types/index.d.ts @@ -35,8 +35,10 @@ import { Uint64 } from '@stdlib/types/number'; * * var a = new Uint64( 4294967296 ); * // returns [ 4294967296n ] +* * var b = setHighWord( a, 2 ); * // returns [ 8589934592n ] +* * var w = getHighWord( b ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js index 8569015072bc..c66264bff6c4 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/index.js @@ -30,8 +30,10 @@ * * var a = new Uint64( 4294967296 ); * // returns [ 4294967296n ] +* * var b = setHighWord( a, 2 ); * // returns [ 8589934592n ] +* * var w = getHighWord( b ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js index 7f71901abf5c..8889bfa6d7b9 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js @@ -38,8 +38,10 @@ var Uint64 = require( '@stdlib/number/uint64/ctor' ); * * var a = new Uint64( 4294967296 ); * // returns [ 4294967296n ] +* * var b = setHighWord( a, 2 ); * // returns [ 8589934592n ] +* * var w = getHighWord( b ); * // returns 2 */ From b7cc73d1759a58f6f0f320b2b4e8623e47cfceba Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:03:07 -0700 Subject: [PATCH 03/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 2 +- .../@stdlib/number/uint64/base/set-high-word/lib/main.js | 3 ++- .../@stdlib/number/uint64/base/set-high-word/test/test.js | 5 ++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 094a1600484f..4225fef416cf 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -18,7 +18,7 @@ limitations under the License. --> -# Set High Word +# setHighWord > Set the high 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js index 8889bfa6d7b9..359101dfd87c 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/lib/main.js @@ -20,6 +20,7 @@ // MODULES // +var getLowWord = require( '@stdlib/number/uint64/base/get-low-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); @@ -46,7 +47,7 @@ var Uint64 = require( '@stdlib/number/uint64/ctor' ); * // returns 2 */ function setHighWord( a, high ) { - return Uint64.of( high, a.lo ); + return Uint64.of( high, getLowWord( a ) ); } diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js index c176eeff9ba0..9701383f4158 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js @@ -24,6 +24,7 @@ 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 setHighWord = require( './../lib' ); @@ -73,9 +74,11 @@ tape( 'the function sets the high 32-bit word of a 64-bit unsigned integer', fun for ( i = 0; i < values.length; i++ ) { v = values[ i ]; a = new Uint64( 0 ); + w = getLowWord( a ); b = setHighWord( a, v ); w = getHighWord( b ); - t.strictEqual( w, v, 'returns expected value' ); + t.strictEqual( getHighWord( b ), v, 'returns expected value' ); + t.strictEqual( getLowWord( b ), w, 'returns expected value' ); } t.end(); }); From 0fa259e67d9c4e3d62adc1f9c71116e64458d8b7 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:04:09 -0700 Subject: [PATCH 04/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/test/test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js index 9701383f4158..3dee8391b415 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/test/test.js @@ -76,7 +76,6 @@ tape( 'the function sets the high 32-bit word of a 64-bit unsigned integer', fun a = new Uint64( 0 ); w = getLowWord( a ); b = setHighWord( a, v ); - w = getHighWord( b ); t.strictEqual( getHighWord( b ), v, 'returns expected value' ); t.strictEqual( getLowWord( b ), w, 'returns expected value' ); } From d94d4d2be951fac82bb9cfd85559ef186bb417ce Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:08:36 -0700 Subject: [PATCH 05/11] docs: update example Signed-off-by: Athan --- .../uint64/base/set-high-word/examples/index.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js index 671256ae2b99..e342e656785e 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js @@ -18,11 +18,18 @@ 'use strict'; +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); var setHighWord = require( './../lib' ); var a = new Uint64( 4294967296 ); -var b = setHighWord( a, 2 ); -console.log( 'value: %s, high word: %s', b, getHighWord( b ) ); -// => 'value: 8589934592, high word: 2' +// returns + +var words = discreteUniform( 100, 0, UINT32_MAX, { + 'dtype': 'uint32' +}); + +logEachMap( 'setHighWord(%s, %s) = %s', a, words, setHighWord ); From 4b2e58342a100f607f6c70cee09e683d06485aea Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:09:46 -0700 Subject: [PATCH 06/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../number/uint64/base/set-high-word/README.md | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 4225fef416cf..03257f7d7d73 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -61,14 +61,21 @@ var w = getHighWord( b ); ```javascript +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); -var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); +var logEachMap = require( '@stdlib/console/log-each-map' ); +var setHighWord = require( '@stdlib/number/uint64/base/get-low-word' ); var a = new Uint64( 4294967296 ); -var b = setHighWord( a, 2 ); -console.log( 'value: %s, high word: %s', b, getHighWord( b ) ); -// => 'value: 8589934592, high word: 2' +// returns + +var words = discreteUniform( 100, 0, UINT32_MAX, { + 'dtype': 'uint32' +}); + +logEachMap( 'setHighWord(%s, %s) = %s', a, words, setHighWord ); ``` From f38c5302c38c7b631a561462c818c51abadeef70 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:10:31 -0700 Subject: [PATCH 07/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 03257f7d7d73..3cf787518279 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -72,7 +72,7 @@ var a = new Uint64( 4294967296 ); // returns var words = discreteUniform( 100, 0, UINT32_MAX, { - 'dtype': 'uint32' + 'dtype': 'uint32' }); logEachMap( 'setHighWord(%s, %s) = %s', a, words, setHighWord ); From 2eabc1bbf438bbc5bd6f5d824fddaaceb4ee1091 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:11:39 -0700 Subject: [PATCH 08/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../number/uint64/base/set-high-word/README.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 3cf787518279..ea52786f119d 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -34,8 +34,6 @@ var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); Sets the high 32-bit word of a [64-bit unsigned integer][@stdlib/number/uint64/ctor]. -The function returns a new `Uint64` instance without modifying the input. - ```javascript var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); @@ -54,6 +52,16 @@ var w = getHighWord( b ); +
+ +## Notes + +- The function returns a new `Uint64` instance without modifying the input. + +
+ + +
## Examples From 7d6e2ef140ab4bfd3fcb685dd5ea727399cda0f1 Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:12:29 -0700 Subject: [PATCH 09/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index ea52786f119d..7c2cfef41958 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -56,7 +56,7 @@ var w = getHighWord( b ); ## Notes -- The function returns a new `Uint64` instance without modifying the input. +- The function returns a new [64-bit unsigned integer][@stdlib/number/uint64/ctor] instance without modifying the input.
From b67a83ca5829e59e508a86441748bfd1aad3139d Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:18:48 -0700 Subject: [PATCH 10/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 1 - .../@stdlib/number/uint64/base/set-high-word/examples/index.js | 1 - 2 files changed, 2 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 7c2cfef41958..19224ff5c60a 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -71,7 +71,6 @@ var w = getHighWord( b ); ```javascript var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); -var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); var logEachMap = require( '@stdlib/console/log-each-map' ); var setHighWord = require( '@stdlib/number/uint64/base/get-low-word' ); diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js index e342e656785e..253c9911cbbf 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/examples/index.js @@ -20,7 +20,6 @@ var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); -var getHighWord = require( '@stdlib/number/uint64/base/get-high-word' ); var Uint64 = require( '@stdlib/number/uint64/ctor' ); var logEachMap = require( '@stdlib/console/log-each-map' ); var setHighWord = require( './../lib' ); From 42dfb611a641ae61aa1a90a86a5d7b4b6a133b5d Mon Sep 17 00:00:00 2001 From: Athan Date: Sat, 18 Jul 2026 15:21:00 -0700 Subject: [PATCH 11/11] Apply suggestions from code review Co-authored-by: Athan Signed-off-by: Athan --- .../@stdlib/number/uint64/base/set-high-word/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md index 19224ff5c60a..48328631e9f6 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/set-high-word/README.md @@ -73,7 +73,7 @@ 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 setHighWord = require( '@stdlib/number/uint64/base/get-low-word' ); +var setHighWord = require( '@stdlib/number/uint64/base/set-high-word' ); var a = new Uint64( 4294967296 ); // returns