From 1895adb7cbe513720decae4c96f03c82b08f5f88 Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Thu, 29 Oct 2026 20:23:26 +0600 Subject: [PATCH 1/3] feat: add `number/uint64/base/and` --- 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 --- --- .../@stdlib/number/uint64/base/and/README.md | 162 ++++++++++++++++++ .../uint64/base/and/benchmark/benchmark.js | 129 ++++++++++++++ .../number/uint64/base/and/docs/repl.txt | 118 +++++++++++++ .../uint64/base/and/docs/types/index.d.ts | 130 ++++++++++++++ .../number/uint64/base/and/docs/types/test.ts | 113 ++++++++++++ .../number/uint64/base/and/examples/index.js | 39 +++++ .../number/uint64/base/and/lib/assign.js | 55 ++++++ .../number/uint64/base/and/lib/index.js | 55 ++++++ .../number/uint64/base/and/lib/main.js | 62 +++++++ .../number/uint64/base/and/lib/strided.js | 59 +++++++ .../number/uint64/base/and/package.json | 64 +++++++ .../uint64/base/and/test/test.assign.js | 71 ++++++++ .../number/uint64/base/and/test/test.js | 44 +++++ .../number/uint64/base/and/test/test.main.js | 113 ++++++++++++ .../uint64/base/and/test/test.strided.js | 81 +++++++++ 15 files changed, 1295 insertions(+) create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/README.md create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/benchmark/benchmark.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/docs/repl.txt create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/lib/assign.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/lib/index.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/lib/main.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/lib/strided.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/package.json create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/test/test.assign.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/test/test.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js create mode 100644 lib/node_modules/@stdlib/number/uint64/base/and/test/test.strided.js diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/README.md b/lib/node_modules/@stdlib/number/uint64/base/and/README.md new file mode 100644 index 000000000000..c9e7a3a53b3d --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/README.md @@ -0,0 +1,162 @@ + + +# and + +> Compute the bitwise AND of two 64-bit unsigned integers. + +
+ +
+ + + +
+ +## Usage + +```javascript +var and = require( '@stdlib/number/uint64/base/and' ); +``` + +#### and( a, b ) + +Computes the bitwise AND of two 64-bit unsigned integers. + +```javascript +var Uint64 = require( '@stdlib/number/uint64/ctor' ); + +var a = new Uint64( 5 ); +var b = new Uint64( 3 ); + +var v = and( a, b ); +// returns [ 1n ] +``` + +#### and.assign( ah, al, bh, bl, out, stride, offset ) + +Computes the bitwise AND of two 64-bit unsigned integers and assigns results to a provided output array. + +```javascript +var Uint32Array = require( '@stdlib/array/uint32' ); + +var out = new Uint32Array( 2 ); +var v = and.assign( 1, 2, 3, 4, out, 1, 0 ); +// returns [ 1, 0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **ah**: high 32-bit word of the first 64-bit unsigned integer. +- **al**: low 32-bit word of the first 64-bit unsigned integer. +- **bh**: high 32-bit word of the second 64-bit unsigned integer. +- **bl**: low 32-bit word of the second 64-bit unsigned integer. +- **out**: output array. +- **stride**: stride length for `out`. +- **offset**: starting index for `out`. + +#### and.strided( a, sa, oa, b, sb, ob, out, so, oo ) + +Computes the bitwise AND of two 64-bit unsigned integers stored in integer-valued strided array views and assigns results to a provided strided output array. + +```javascript +var Uint32Array = require( '@stdlib/array/uint32' ); + +var a = new Uint32Array( [ 1, 2 ] ); +var b = new Uint32Array( [ 3, 4 ] ); +var out = new Uint32Array( 2 ); + +var v = and.strided( a, 1, 0, b, 1, 0, out, 1, 0 ); +// returns [ 1, 0 ] + +var bool = ( out === v ); +// returns true +``` + +The function supports the following parameters: + +- **a**: first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words. +- **sa**: stride length for `a`. +- **oa**: starting index for `a`. +- **b**: second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words. +- **sb**: stride length for `b`. +- **ob**: starting index for `b`. +- **out**: output array. +- **so**: stride length for `out`. +- **oo**: starting index for `out`. + +
+ + + +
+ +## Examples + + + +```javascript +var words2uint64 = require( '@stdlib/number/uint64/ctor' ).of; +var and = require( '@stdlib/number/uint64/base/and' ); + +// Define a mask that only keeps the middle 32 bits (bits 16 to 47): +var mask = words2uint64( 0x0000ffff, 0xffff0000 ); + +var values = [ + words2uint64( 0x12345678, 0x9abcdef0 ), + words2uint64( 0x11112222, 0x33334444 ), + words2uint64( 0xaaaabbbb, 0xccccdddd ), + words2uint64( 0xffffffff, 0xffffffff ) +]; + +var v; +var i; +for ( i = 0; i < values.length; i++ ) { + v = and( values[ i ], mask ); + console.log( '0x%s & 0x%s = 0x%s', values[ i ].toString( 16 ), mask.toString( 16 ), v.toString( 16 ) ); +} +``` + +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/benchmark/benchmark.js b/lib/node_modules/@stdlib/number/uint64/base/and/benchmark/benchmark.js new file mode 100644 index 000000000000..46de51a233fe --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/benchmark/benchmark.js @@ -0,0 +1,129 @@ +/** +* @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 Uint32Array = require( '@stdlib/array/uint32' ); +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 format = require( '@stdlib/string/format' ); +var pkg = require( './../package.json' ).name; +var and = require( './../lib' ); + + +// VARIABLES // + +var options = { + 'dtype': 'uint32' +}; + + +// MAIN // + +bench( pkg, function benchmark( b ) { + var values; + var out; + var N; + var x; + var y; + var z; + var i; + + N = 100; + x = discreteUniform( N, 0, UINT32_MAX, options ); + values = []; + for ( i = 0; i < N; i++ ) { + values.push( Uint64.of( x[ i ], x[ (i+1)%N ] ) ); + } + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + y = values[ i%N ]; + z = values[ (i+1)%N ]; + out = and( y, z ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !( out instanceof Uint64 ) ) { + b.fail( 'should return a Uint64 instance' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:assign', pkg ), function benchmark( b ) { + var out; + var N; + var x; + var i; + + N = 100; + x = discreteUniform( N, 0, UINT32_MAX, options ); + + out = new Uint32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + out = and.assign( x[ i%N ], x[ (i+1)%N ], x[ (i+2)%N ], x[ (i+3)%N ], out, 1, 0 ); // eslint-disable-line max-len + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !( out instanceof Uint32Array ) ) { + b.fail( 'should return a Uint32Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + +bench( format( '%s:strided', pkg ), function benchmark( b ) { + var out; + var N; + var x; + var y; + var i; + var j; + + N = 50; + x = discreteUniform( N*2, 0, UINT32_MAX, options ); + y = discreteUniform( N*2, 0, UINT32_MAX, options ); + + out = new Uint32Array( 2 ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + j = ( i % N ) * 2; + out = and.strided( x, 1, j, y, 1, j, out, 1, 0 ); + if ( typeof out !== 'object' ) { + b.fail( 'should return an object' ); + } + } + b.toc(); + if ( !( out instanceof Uint32Array ) ) { + b.fail( 'should return a Uint32Array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/docs/repl.txt b/lib/node_modules/@stdlib/number/uint64/base/and/docs/repl.txt new file mode 100644 index 000000000000..df533406bd99 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/docs/repl.txt @@ -0,0 +1,118 @@ + +{{alias}}( a, b ) + Computes the bitwise AND of two 64-bit unsigned integers. + + Parameters + ---------- + a: Uint64 + 64-bit unsigned integer. + + b: Uint64 + 64-bit unsigned integer. + + Returns + ------- + out: Uint64 + Result. + + Examples + -------- + > var a = new {{alias:@stdlib/number/uint64/ctor}}( 5 ) + [ 5n ] + > var b = new {{alias:@stdlib/number/uint64/ctor}}( 3 ) + [ 3n ] + > var out = {{alias}}( a, b ) + [ 1n ] + + +{{alias}}.assign( ah, al, bh, bl, out, stride, offset ) + Computes the bitwise AND of two 64-bit unsigned integers and assigns results + to a provided output array. + + Parameters + ---------- + ah: integer + High 32-bit word of the first 64-bit unsigned integer. + + al: integer + Low 32-bit word of the first 64-bit unsigned integer. + + bh: integer + High 32-bit word of the second 64-bit unsigned integer. + + bl: integer + Low 32-bit word of the second 64-bit unsigned integer. + + out: ArrayLikeObject + Output array. + + stride: integer + Stride length. + + offset: integer + Starting index. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var out = new {{alias:@stdlib/array/uint32}}( 2 ); + > {{alias}}.assign( 1, 2, 3, 4, out, 1, 0 ) + [ 1, 0 ] + + +{{alias}}.strided( a, sa, oa, b, sb, ob, out, so, oo ) + Computes the bitwise AND of two 64-bit unsigned integers stored in + integer-valued strided array views and assigns results to a provided + strided output array. + + Parameters + ---------- + a: ArrayLikeObject + First 64-bit unsigned integer strided array view containing interleaved + 32-bit unsigned integer high and low order words. + + sa: integer + Stride length for `a`. + + oa: integer + Starting index for `a`. + + b: ArrayLikeObject + Second 64-bit unsigned integer strided array view containing interleaved + 32-bit unsigned integer high and low order words. + + sb: integer + Stride length for `b`. + + ob: integer + Starting index for `b`. + + out: ArrayLikeObject + Output array. + + so: integer + Stride length for `out`. + + oo: integer + Starting index for `out`. + + Returns + ------- + out: ArrayLikeObject + Output array. + + Examples + -------- + > var a = new {{alias:@stdlib/array/uint32}}( [ 1, 2 ] ); + > var b = new {{alias:@stdlib/array/uint32}}( [ 3, 4 ] ); + > var out = new {{alias:@stdlib/array/uint32}}( 2 ); + > {{alias}}.strided( a, 1, 0, b, 1, 0, out, 1, 0 ) + [ 1, 0 ] + + See Also + -------- + diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/index.d.ts b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/index.d.ts new file mode 100644 index 000000000000..2ae627f7f525 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/index.d.ts @@ -0,0 +1,130 @@ +/* +* @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'; +import { Collection, NumericArray } from '@stdlib/types/array'; + +/** +* Interface for computing the bitwise AND of two 64-bit unsigned integers. +*/ +interface And { + /** + * Computes the bitwise AND of two 64-bit unsigned integers. + * + * @param a - 64-bit unsigned integer + * @param b - 64-bit unsigned integer + * @returns result + * + * @example + * var Uint64 = require( '@stdlib/number/uint64/ctor' ); + * + * var a = new Uint64( 5 ); + * var b = new Uint64( 3 ); + * + * var v = and( a, b ); + * // returns [ 1n ] + */ + ( a: Uint64, b: Uint64 ): Uint64; + + /** + * Computes the bitwise AND of two 64-bit unsigned integers and assigns results to a provided output array. + * + * @param ah - high 32-bit word of the first 64-bit unsigned integer + * @param al - low 32-bit word of the first 64-bit unsigned integer + * @param bh - high 32-bit word of the second 64-bit unsigned integer + * @param bl - low 32-bit word of the second 64-bit unsigned integer + * @param out - output array + * @param stride - stride length + * @param offset - starting index + * @returns output array + * + * @example + * var Uint32Array = require( '@stdlib/array/uint32' ); + * + * var out = and.assign( 1, 2, 3, 4, new Uint32Array( 2 ), 1, 0 ); + * // returns [ 1, 0 ] + */ + assign>( ah: number, al: number, bh: number, bl: number, out: T, stride: number, offset: number ): T; + + /** + * Computes the bitwise AND of two 64-bit unsigned integers stored in integer-valued strided array views and assigns results to a provided strided output array. + * + * @param a - first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words + * @param sa - stride length for `a` + * @param oa - starting index for `a` + * @param b - second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words + * @param sb - stride length for `b` + * @param ob - starting index for `b` + * @param out - output array + * @param so - stride length for `out` + * @param oo - starting index for `out` + * @returns output array + * + * @example + * var Uint32Array = require( '@stdlib/array/uint32' ); + * + * var a = new Uint32Array( [ 1, 2 ] ); + * var b = new Uint32Array( [ 3, 4 ] ); + * + * var out = and.strided( a, 1, 0, b, 1, 0, new Uint32Array( 2 ), 1, 0 ); + * // returns [ 1, 0 ] + */ + strided, U extends NumericArray | Collection, V extends NumericArray | Collection>( a: T, sa: number, oa: number, b: U, sb: number, ob: number, out: V, so: number, oo: number ): V; +} + +/** +* Computes the bitwise AND of two 64-bit unsigned integers. +* +* @param a - 64-bit unsigned integer +* @param b - 64-bit unsigned integer +* @returns result +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 5 ); +* var b = new Uint64( 3 ); +* +* var v = and( a, b ); +* // returns [ 1n ] +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var out = and.assign( 1, 2, 3, 4, new Uint32Array( 2 ), 1, 0 ); +* // returns [ 1, 0 ] +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var a = new Uint32Array( [ 1, 2 ] ); +* var b = new Uint32Array( [ 3, 4 ] ); +* +* var out = and.strided( a, 1, 0, b, 1, 0, new Uint32Array( 2 ), 1, 0 ); +* // returns [ 1, 0 ] +*/ +declare var and: And; + + +// EXPORTS // + +export = and; diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts new file mode 100644 index 000000000000..641fdc3461a3 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts @@ -0,0 +1,113 @@ +/* +* @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 and = require( './index' ); + + +// TESTS // + +// The function returns a 64-bit unsigned integer... +{ + const a = new Uint64( 5 ); + + and( a, a ); // $ExpectType Uint64 +} + +// The compiler throws an error if the function is provided a first argument which is not a 64-bit unsigned integer... +{ + const a = new Uint64( 5 ); + + and( true, a ); // $ExpectError + and( false, a ); // $ExpectError + and( null, a ); // $ExpectError + and( undefined, a ); // $ExpectError + and( '5', a ); // $ExpectError + and( [], a ); // $ExpectError + and( {}, a ); // $ExpectError + and( ( x: number ): number => x, a ); // $ExpectError +} + +// The compiler throws an error if the function is provided a second argument which is not a 64-bit unsigned integer... +{ + const a = new Uint64( 5 ); + + and( a, true ); // $ExpectError + and( a, false ); // $ExpectError + and( a, null ); // $ExpectError + and( a, undefined ); // $ExpectError + and( a, '5' ); // $ExpectError + and( a, [] ); // $ExpectError + and( a, {} ); // $ExpectError + and( 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 ); + + and(); // $ExpectError + and( a ); // $ExpectError + and( a, a, a ); // $ExpectError +} + +// Attached to main export is an `assign` method which returns a collection... +{ + const out = [ 0, 0 ]; + + and.assign( 1, 2, 3, 4, out, 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `assign` method is provided invalid arguments... +{ + const out = [ 0, 0 ]; + + and.assign( '5', 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, '2', 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, '3', 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, '4', out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, 123, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, '1', 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, '0' ); // $ExpectError +} + +// Attached to main export is a `strided` method which returns a collection... +{ + const a = [ 1, 2 ]; + const b = [ 3, 4 ]; + const out = [ 0, 0 ]; + + and.strided( a, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `strided` method is provided invalid arguments... +{ + const a = [ 1, 2 ]; + const b = [ 3, 4 ]; + const out = [ 0, 0 ]; + + and.strided( 123, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, '1', 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, '0', b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, 123, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, '1', 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, '0', out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, 123, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, '1', 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, '0' ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js new file mode 100644 index 000000000000..4573649e7aca --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js @@ -0,0 +1,39 @@ +/** +* @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 words2uint64 = require( '@stdlib/number/uint64/ctor' ).of; +var and = require( './../lib' ); + +// Define a mask that only keeps the middle 32 bits (bits 16 to 47): +var mask = words2uint64( 0x0000ffff, 0xffff0000 ); + +var values = [ + words2uint64( 0x12345678, 0x9abcdef0 ), + words2uint64( 0x11112222, 0x33334444 ), + words2uint64( 0xaaaabbbb, 0xccccdddd ), + words2uint64( 0xffffffff, 0xffffffff ) +]; + +var v; +var i; +for ( i = 0; i < values.length; i++ ) { + v = and( values[ i ], mask ); + console.log( '0x%s & 0x%s = 0x%s', values[ i ].toString( 16 ), mask.toString( 16 ), v.toString( 16 ) ); +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/lib/assign.js b/lib/node_modules/@stdlib/number/uint64/base/and/lib/assign.js new file mode 100644 index 000000000000..1bb7cfa46a0b --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/lib/assign.js @@ -0,0 +1,55 @@ +/** +* @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 // + +/** +* Computes the bitwise AND of two 64-bit unsigned integers and assigns results to a provided output array. +* +* @param {uinteger} ah - high 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} al - low 32-bit word of the first 64-bit unsigned integer +* @param {uinteger} bh - high 32-bit word of the second 64-bit unsigned integer +* @param {uinteger} bl - low 32-bit word of the second 64-bit unsigned integer +* @param {Collection} out - output array +* @param {integer} stride - stride length +* @param {NonNegativeInteger} offset - starting index +* @returns {Collection} output array +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var out = assign( 1, 2, 3, 4, new Uint32Array( 2 ), 1, 0 ); +* // returns [ 1, 0 ] +*/ +function assign( ah, al, bh, bl, out, stride, offset ) { + ah >>>= 0; + al >>>= 0; + bh >>>= 0; + bl >>>= 0; + + out[ offset ] = ( ah & bh ) >>> 0; // hi + out[ offset + stride ] = ( al & bl ) >>> 0; // lo + return out; +} + + +// EXPORTS // + +module.exports = assign; diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/lib/index.js b/lib/node_modules/@stdlib/number/uint64/base/and/lib/index.js new file mode 100644 index 000000000000..ca24d63473a4 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/lib/index.js @@ -0,0 +1,55 @@ +/** +* @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'; + +/** +* Compute the bitwise AND of two 64-bit unsigned integers. +* +* @module @stdlib/number/uint64/base/and +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* var and = require( '@stdlib/number/uint64/base/and' ); +* +* var a = new Uint64( 5 ); +* var b = new Uint64( 3 ); +* +* var v = and( a, b ); +* // returns [ 1n ] +*/ + +// MODULES // + +var setReadOnly = require( '@stdlib/utils/define-nonenumerable-read-only-property' ); +var main = require( './main.js' ); +var assign = require( './assign.js' ); +var strided = require( './strided.js' ); + + +// MAIN // + +setReadOnly( main, 'assign', assign ); +setReadOnly( main, 'strided', strided ); + + +// EXPORTS // + +module.exports = main; + +// exports: { "assign": "main.assign", "strided": "main.strided" } diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/lib/main.js b/lib/node_modules/@stdlib/number/uint64/base/and/lib/main.js new file mode 100644 index 000000000000..fc94be79d9f6 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/lib/main.js @@ -0,0 +1,62 @@ +/** +* @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 Uint32Array = require( '@stdlib/array/uint32' ); +var toWords = require( '@stdlib/number/uint64/base/to-words' ).assign; +var words2uint64 = require( '@stdlib/number/uint64/ctor' ).of; +var assign = require( './assign.js' ); + + +// VARIABLES // + +var WORKSPACE = new Uint32Array( 6 ); + + +// MAIN // + +/** +* Computes the bitwise AND of two 64-bit unsigned integers. +* +* @param {Uint64} a - 64-bit unsigned integer +* @param {Uint64} b - 64-bit unsigned integer +* @returns {Uint64} result +* +* @example +* var Uint64 = require( '@stdlib/number/uint64/ctor' ); +* +* var a = new Uint64( 5 ); +* var b = new Uint64( 3 ); +* +* var v = and( a, b ); +* // returns [ 1n ] +*/ +function and( a, b ) { + toWords( a, WORKSPACE, 1, 0 ); + toWords( b, WORKSPACE, 1, 2 ); + assign( WORKSPACE[ 0 ], WORKSPACE[ 1 ], WORKSPACE[ 2 ], WORKSPACE[ 3 ], WORKSPACE, 1, 4 ); // eslint-disable-line max-len + return words2uint64( WORKSPACE[ 4 ], WORKSPACE[ 5 ] ); +} + + +// EXPORTS // + +module.exports = and; diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/lib/strided.js b/lib/node_modules/@stdlib/number/uint64/base/and/lib/strided.js new file mode 100644 index 000000000000..894b4392d324 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/lib/strided.js @@ -0,0 +1,59 @@ +/** +* @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 assign = require( './assign.js' ); + + +// MAIN // + +/** +* Computes the bitwise AND of two 64-bit unsigned integers stored in integer-valued strided array views and assigns results to a provided strided output array. +* +* @param {Collection} a - first 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words +* @param {integer} sa - stride length for `a` +* @param {NonNegativeInteger} oa - starting index for `a` +* @param {Collection} b - second 64-bit unsigned integer strided array view containing interleaved 32-bit unsigned integer high and low order words +* @param {integer} sb - stride length for `b` +* @param {NonNegativeInteger} ob - starting index for `b` +* @param {Collection} out - output array +* @param {integer} so - stride length for `out` +* @param {NonNegativeInteger} oo - starting index for `out` +* @returns {Collection} output array +* +* @example +* var Uint32Array = require( '@stdlib/array/uint32' ); +* +* var a = new Uint32Array( [ 1, 2 ] ); +* var b = new Uint32Array( [ 3, 4 ] ); +* +* var out = strided( a, 1, 0, b, 1, 0, new Uint32Array( 2 ), 1, 0 ); +* // returns [ 1, 0 ] +*/ +function strided( a, sa, oa, b, sb, ob, out, so, oo ) { + assign( a[ oa ], a[ oa+sa ], b[ ob ], b[ ob+sb ], out, so, oo ); + return out; +} + + +// EXPORTS // + +module.exports = strided; diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/package.json b/lib/node_modules/@stdlib/number/uint64/base/and/package.json new file mode 100644 index 000000000000..dc0ad55e8d13 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/package.json @@ -0,0 +1,64 @@ +{ + "name": "@stdlib/number/uint64/base/and", + "version": "0.0.0", + "description": "Compute the bitwise AND of two 64-bit unsigned integers.", + "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", + "stdmath", + "mathematics", + "math", + "and", + "and64", + "bitwise", + "bitwise-and", + "unsigned", + "uint64", + "integer" + ] +} diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.assign.js b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.assign.js new file mode 100644 index 000000000000..ef2bfcbc7919 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.assign.js @@ -0,0 +1,71 @@ +/** +* @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 isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var and = require( './../lib/assign.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof and, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the bitwise and of two 64-bit unsigned integers', function test( t ) { + var expected; + var out; + var v; + + // Trivial stride and offset: + out = new Uint32Array( 2 ); + v = and( 1, 2, 3, 4, out, 1, 0 ); + expected = new Uint32Array( [ 1, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Positive stride: + out = new Uint32Array( 4 ); + v = and( 1, 2, 3, 4, out, 2, 0 ); + expected = new Uint32Array( [ 1, 0, 0, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Positive stride and non-zero offset: + out = new Uint32Array( 4 ); + v = and( 1, 2, 3, 4, out, 2, 1 ); + expected = new Uint32Array( [ 0, 1, 0, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Negative stride and non-zero offset: + out = new Uint32Array( 2 ); + v = and( 1, 2, 3, 4, out, -1, 1 ); + expected = new Uint32Array( [ 0, 1 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.js b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.js new file mode 100644 index 000000000000..eb1703b72531 --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.js @@ -0,0 +1,44 @@ +/** +* @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 isMethod = require( '@stdlib/assert/is-method' ); +var and = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof and, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'attached to the main export is an `assign` method', function test( t ) { + t.strictEqual( isMethod( and, 'assign' ), true, 'returns expected value' ); + t.end(); +}); + +tape( 'attached to the main export is a `strided` method', function test( t ) { + t.strictEqual( isMethod( and, 'strided' ), true, 'returns expected value' ); + t.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js new file mode 100644 index 000000000000..d6dc493e0c5c --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js @@ -0,0 +1,113 @@ +/** +* @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 hasBigIntSupport = require( '@stdlib/assert/has-bigint-support' ); +var BigInt = require( '@stdlib/bigint/ctor' ); +var UINT32_MAX = require( '@stdlib/constants/uint32/max' ); +var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' ); +var Uint64 = require( '@stdlib/number/uint64/ctor' ); +var discreteUniform = require( '@stdlib/random/array/discrete-uniform' ); +var and = require( './../lib' ); + + +// VARIABLES // + +var opts = { + 'skip': !hasBigIntSupport() +}; + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof and, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the bitwise and of two 64-bit unsigned integers', function test( t ) { + var expected; + var out; + var a; + var b; + + // Small value: + a = new Uint64( 5 ); + b = new Uint64( 3 ); + out = and( a, b ); + expected = new Uint64( 1 ); + t.ok( isEqual( out, expected ), 'returns expected value' ); + + // Same value: + a = new Uint64( 9876543210 ); + b = new Uint64( 9876543210 ); + out = and( a, b ); + expected = new Uint64( 9876543210 ); + t.ok( isEqual( out, expected ), 'returns expected value' ); + + // Zero value: + a = new Uint64( 12345 ); + b = new Uint64( 0 ); + out = and( a, b ); + expected = new Uint64( 0 ); + t.ok( isEqual( out, expected ), 'returns expected value' ); + + // Large disjoint values: + a = Uint64.of( 0, UINT32_MAX ); + b = Uint64.of( UINT32_MAX, 0 ); + out = and( a, b ); + expected = Uint64.of( 0, 0 ); + t.ok( isEqual( out, expected ), 'returns expected value' ); + + t.end(); +}); + +tape( 'the function computes the bitwise and of two 64-bit unsigned integers (random values)', opts, function test( t ) { + var big64andsum; + var expected; + var values; + var out; + var a; + var b; + var x; + var i; + + x = discreteUniform( 100, 0, UINT32_MAX, { + 'dtype': 'uint32' + }); + values = []; + for ( i = 0; i < x.length; i++ ) { + values.push( Uint64.of( x[ i ], x[ (i+1)%x.length ] ) ); + } + + for ( i = 0; i < values.length; i++ ) { + a = values[ i ]; + b = values[ (i+1)%values.length ]; + out = and( a, b ); + big64andsum = BigInt.asUintN( 64, a.valueOf() & b.valueOf() ); + expected = new Uint64( big64andsum ); + t.ok( isEqual( out, expected ), 'returns expected value' ); + } + + t.end(); +}); diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.strided.js b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.strided.js new file mode 100644 index 000000000000..78ffbec7999f --- /dev/null +++ b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.strided.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 isEqualUint32Array = require( '@stdlib/assert/is-equal-uint32array' ); +var Uint32Array = require( '@stdlib/array/uint32' ); +var and = require( './../lib/strided.js' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof and, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function computes the bitwise and of two 64-bit unsigned integers', function test( t ) { + var expected; + var out; + var a; + var b; + var v; + + // Trivial stride and offset: + a = new Uint32Array( [ 1, 2 ] ); + b = new Uint32Array( [ 3, 4 ] ); + out = new Uint32Array( 2 ); + v = and( a, 1, 0, b, 1, 0, out, 1, 0 ); + expected = new Uint32Array( [ 1, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Positive stride: + a = new Uint32Array( [ 1, 0, 0, 2, 0, 0 ] ); + b = new Uint32Array( [ 3, 0, 4, 0 ] ); + out = new Uint32Array( 2 ); + v = and( a, 3, 0, b, 2, 0, out, 1, 0 ); + expected = new Uint32Array( [ 1, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Positive stride and non-zero offset: + a = new Uint32Array( [ 0, 0, 1, 0, 0, 2 ] ); + b = new Uint32Array( [ 0, 3, 0, 4 ] ); + out = new Uint32Array( 2 ); + v = and( a, 3, 2, b, 2, 1, out, 1, 0 ); + expected = new Uint32Array( [ 1, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + // Negative stride and non-zero offset: + a = new Uint32Array( [ 0, 0, 2, 0, 0, 1 ] ); + b = new Uint32Array( [ 0, 4, 0, 3 ] ); + out = new Uint32Array( 2 ); + v = and( a, -3, 5, b, -2, 3, out, 1, 0 ); + expected = new Uint32Array( [ 1, 0 ] ); + t.strictEqual( v, out, 'returns expected value' ); + t.ok( isEqualUint32Array( out, expected ), 'returns expected value' ); + + t.end(); +}); From ccd1a8c232ef70ec34cd69fcaba32c25da9ce0b4 Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Fri, 6 Nov 2026 00:12:29 +0600 Subject: [PATCH 2/3] docs: update example --- 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: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: passed - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - 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: na - task: lint_license_headers status: passed --- --- .../@stdlib/number/uint64/base/and/README.md | 18 ++++++++++++------ .../number/uint64/base/and/examples/index.js | 8 +++++++- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/README.md b/lib/node_modules/@stdlib/number/uint64/base/and/README.md index c9e7a3a53b3d..c2929319d027 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/and/README.md @@ -117,23 +117,29 @@ The function supports the following parameters: ```javascript var words2uint64 = require( '@stdlib/number/uint64/ctor' ).of; +var lpad = require( '@stdlib/string/base/left-pad' ); var and = require( '@stdlib/number/uint64/base/and' ); // Define a mask that only keeps the middle 32 bits (bits 16 to 47): var mask = words2uint64( 0x0000ffff, 0xffff0000 ); +// Define a function for converting to 64-bit fixed length hex string +function toHex64( x ) { + return '0x'+lpad( x.toString( 16 ), 16, '0' ); +} + var values = [ - words2uint64( 0x12345678, 0x9abcdef0 ), - words2uint64( 0x11112222, 0x33334444 ), - words2uint64( 0xaaaabbbb, 0xccccdddd ), - words2uint64( 0xffffffff, 0xffffffff ) + words2uint64( 0x12345678, 0x9abcdef0 ), + words2uint64( 0x11112222, 0x33334444 ), + words2uint64( 0xaaaabbbb, 0xccccdddd ), + words2uint64( 0xffffffff, 0xffffffff ) ]; var v; var i; for ( i = 0; i < values.length; i++ ) { - v = and( values[ i ], mask ); - console.log( '0x%s & 0x%s = 0x%s', values[ i ].toString( 16 ), mask.toString( 16 ), v.toString( 16 ) ); + v = and( values[ i ], mask ); + console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( v ) ); } ``` diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js index 4573649e7aca..e08ff8877a4a 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js @@ -19,11 +19,17 @@ 'use strict'; var words2uint64 = require( '@stdlib/number/uint64/ctor' ).of; +var lpad = require( '@stdlib/string/base/left-pad' ); var and = require( './../lib' ); // Define a mask that only keeps the middle 32 bits (bits 16 to 47): var mask = words2uint64( 0x0000ffff, 0xffff0000 ); +// Define a function for converting to 64-bit fixed length hex string +function toHex64( x ) { + return '0x'+lpad( x.toString( 16 ), 16, '0' ); +} + var values = [ words2uint64( 0x12345678, 0x9abcdef0 ), words2uint64( 0x11112222, 0x33334444 ), @@ -35,5 +41,5 @@ var v; var i; for ( i = 0; i < values.length; i++ ) { v = and( values[ i ], mask ); - console.log( '0x%s & 0x%s = 0x%s', values[ i ].toString( 16 ), mask.toString( 16 ), v.toString( 16 ) ); + console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( v ) ); } From 36db46dd34a5a98daf3e3466570a0130ad38ef8c Mon Sep 17 00:00:00 2001 From: Abdul Kaium Date: Sat, 5 Dec 2026 03:13:08 +0600 Subject: [PATCH 3/3] chore: address review comments --- .../@stdlib/number/uint64/base/and/README.md | 9 +- .../number/uint64/base/and/docs/types/test.ts | 302 ++++++++++++++++-- .../number/uint64/base/and/examples/index.js | 4 +- .../number/uint64/base/and/test/test.main.js | 6 +- 4 files changed, 282 insertions(+), 39 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/README.md b/lib/node_modules/@stdlib/number/uint64/base/and/README.md index c2929319d027..5039135aa35a 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/README.md +++ b/lib/node_modules/@stdlib/number/uint64/base/and/README.md @@ -50,6 +50,11 @@ var v = and( a, b ); // returns [ 1n ] ``` +The function supports the following parameters: + +- **a**: first 64-bit unsigned integer. +- **b**: second 64-bit unsigned integer. + #### and.assign( ah, al, bh, bl, out, stride, offset ) Computes the bitwise AND of two 64-bit unsigned integers and assigns results to a provided output array. @@ -135,11 +140,9 @@ var values = [ words2uint64( 0xffffffff, 0xffffffff ) ]; -var v; var i; for ( i = 0; i < values.length; i++ ) { - v = and( values[ i ], mask ); - console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( v ) ); + console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( and( values[ i ], mask ) ) ); } ``` diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts index 641fdc3461a3..f2f0a180ffce 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts +++ b/lib/node_modules/@stdlib/number/uint64/base/and/docs/types/test.ts @@ -66,48 +66,290 @@ import and = require( './index' ); and( a, a, a ); // $ExpectError } -// Attached to main export is an `assign` method which returns a collection... +// Attached to the main export is an `assign` method which returns a collection... { - const out = [ 0, 0 ]; - - and.assign( 1, 2, 3, 4, out, 1, 0 ); // $ExpectType number[] + and.assign( 1, 2, 3, 4, new Uint32Array( 2 ), 1, 0 ); // $ExpectType Uint32Array + and.assign( 1, 2, 3, 4, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + and.assign( 1, 2, 3, 4, [ 0, 0 ], 1, 0 ); // $ExpectType number[] } -// The compiler throws an error if the `assign` method is provided invalid arguments... +// The compiler throws an error if the `assign` method is provided a first argument which is not a number... { - const out = [ 0, 0 ]; + const out = new Uint32Array( 2 ); + and.assign( true, 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( false, 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( null, 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( undefined, 2, 3, 4, out, 1, 0 ); // $ExpectError and.assign( '5', 2, 3, 4, out, 1, 0 ); // $ExpectError - and.assign( 1, '2', 3, 4, out, 1, 0 ); // $ExpectError - and.assign( 1, 2, '3', 4, out, 1, 0 ); // $ExpectError - and.assign( 1, 2, 3, '4', out, 1, 0 ); // $ExpectError - and.assign( 1, 2, 3, 4, 123, 1, 0 ); // $ExpectError - and.assign( 1, 2, 3, 4, out, '1', 0 ); // $ExpectError - and.assign( 1, 2, 3, 4, out, 1, '0' ); // $ExpectError + and.assign( [], 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( {}, 2, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( ( x: number ): number => x, 2, 3, 4, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a second argument which is not a number... +{ + const out = new Uint32Array( 2 ); + + and.assign( 1, true, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, false, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, null, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, undefined, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, '5', 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, [], 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, {}, 3, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, ( x: number ): number => x, 3, 4, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a third argument which is not a number... +{ + const out = new Uint32Array( 2 ); + + and.assign( 1, 2, true, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, false, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, null, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, undefined, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, '5', 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, [], 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, {}, 4, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, ( x: number ): number => x, 4, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fourth argument which is not a number... +{ + const out = new Uint32Array( 2 ); + + and.assign( 1, 2, 3, true, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, false, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, null, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, undefined, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, '5', out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, [], out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, {}, out, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a fifth argument which is not a collection... +{ + and.assign( 1, 2, 3, 4, 1, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, true, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, false, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, null, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, undefined, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, '5', 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, [ '5' ], 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, {}, 1, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a sixth argument which is not a number... +{ + const out = new Uint32Array( 2 ); + + and.assign( 1, 2, 3, 4, out, true, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, false, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, null, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, undefined, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, '5', 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, [], 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, {}, 0 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, ( x: number ): number => x, 0 ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided a seventh argument which is not a number... +{ + const out = new Uint32Array( 2 ); + + and.assign( 1, 2, 3, 4, out, 1, true ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, false ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, null ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, undefined ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, '5' ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, [] ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, {} ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, ( x: number ): number => x ); // $ExpectError +} + +// The compiler throws an error if the `assign` method is provided an unsupported number of arguments... +{ + const out = new Uint32Array( 2 ); + + and.assign(); // $ExpectError + and.assign( 1 ); // $ExpectError + and.assign( 1, 2 ); // $ExpectError + and.assign( 1, 2, 3 ); // $ExpectError + and.assign( 1, 2, 3, 4 ); // $ExpectError + and.assign( 1, 2, 3, 4, out ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1 ); // $ExpectError + and.assign( 1, 2, 3, 4, out, 1, 0, {} ); // $ExpectError +} + +// Attached to the main export is a `strided` method which returns a collection... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + and.strided( a, 1, 0, b, 1, 0, new Uint32Array( 2 ), 1, 0 ); // $ExpectType Uint32Array + and.strided( a, 1, 0, b, 1, 0, new Float64Array( 2 ), 1, 0 ); // $ExpectType Float64Array + and.strided( a, 1, 0, b, 1, 0, [ 0, 0 ], 1, 0 ); // $ExpectType number[] +} + +// The compiler throws an error if the `strided` method is provided a first argument which is not a collection... +{ + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( true, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( false, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( null, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( undefined, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( '5', 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( [ '5' ], 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( {}, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( ( x: number ): number => x, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a second argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, true, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, false, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, null, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, undefined, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, '5', 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, [], 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, {}, 0, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, ( x: number ): number => x, 0, b, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a third argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, 1, true, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, false, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, null, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, undefined, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, '5', b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, [], b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, {}, b, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, ( x: number ): number => x, b, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fourth argument which is not a collection... +{ + const a = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, 1, 0, true, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, false, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, null, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, undefined, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, '5', 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, [ '5' ], 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, {}, 1, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, ( x: number ): number => x, 1, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a fifth argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, 1, 0, b, true, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, false, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, null, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, undefined, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, '5', 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, [], 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, {}, 0, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, ( x: number ): number => x, 0, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a sixth argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, 1, 0, b, 1, true, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, false, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, null, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, undefined, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, '5', out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, [], out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, {}, out, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, ( x: number ): number => x, out, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided a seventh argument which is not a collection... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + + and.strided( a, 1, 0, b, 1, 0, 1, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, true, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, false, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, null, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, undefined, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, '5', 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, [ '5' ], 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, {}, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, ( x: number ): number => x, 1, 0 ); // $ExpectError +} + +// The compiler throws an error if the `strided` method is provided an eighth argument which is not a number... +{ + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); + + and.strided( a, 1, 0, b, 1, 0, out, true, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, false, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, null, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, undefined, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, '5', 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, [], 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, {}, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, ( x: number ): number => x, 0 ); // $ExpectError } -// Attached to main export is a `strided` method which returns a collection... +// The compiler throws an error if the `strided` method is provided a ninth argument which is not a number... { - const a = [ 1, 2 ]; - const b = [ 3, 4 ]; - const out = [ 0, 0 ]; + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); - and.strided( a, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectType number[] + and.strided( a, 1, 0, b, 1, 0, out, 1, true ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, false ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, null ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, undefined ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, '5' ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, [] ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, {} ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, ( x: number ): number => x ); // $ExpectError } -// The compiler throws an error if the `strided` method is provided invalid arguments... +// The compiler throws an error if the `strided` method is provided an unsupported number of arguments... { - const a = [ 1, 2 ]; - const b = [ 3, 4 ]; - const out = [ 0, 0 ]; + const a = new Uint32Array( 2 ); + const b = new Uint32Array( 2 ); + const out = new Uint32Array( 2 ); - and.strided( 123, 1, 0, b, 1, 0, out, 1, 0 ); // $ExpectError - and.strided( a, '1', 0, b, 1, 0, out, 1, 0 ); // $ExpectError - and.strided( a, 1, '0', b, 1, 0, out, 1, 0 ); // $ExpectError - and.strided( a, 1, 0, 123, 1, 0, out, 1, 0 ); // $ExpectError - and.strided( a, 1, 0, b, '1', 0, out, 1, 0 ); // $ExpectError - and.strided( a, 1, 0, b, 1, '0', out, 1, 0 ); // $ExpectError - and.strided( a, 1, 0, b, 1, 0, 123, 1, 0 ); // $ExpectError - and.strided( a, 1, 0, b, 1, 0, out, '1', 0 ); // $ExpectError - and.strided( a, 1, 0, b, 1, 0, out, 1, '0' ); // $ExpectError + and.strided(); // $ExpectError + and.strided( a ); // $ExpectError + and.strided( a, 1 ); // $ExpectError + and.strided( a, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b ); // $ExpectError + and.strided( a, 1, 0, b, 1 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1 ); // $ExpectError + and.strided( a, 1, 0, b, 1, 0, out, 1, 0, {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js index e08ff8877a4a..7a074700d52f 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint64/base/and/examples/index.js @@ -37,9 +37,7 @@ var values = [ words2uint64( 0xffffffff, 0xffffffff ) ]; -var v; var i; for ( i = 0; i < values.length; i++ ) { - v = and( values[ i ], mask ); - console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( v ) ); + console.log( '%s & %s = %s', toHex64( values[ i ] ), toHex64( mask ), toHex64( and( values[ i ], mask ) ) ); } diff --git a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js index d6dc493e0c5c..0b2b120635c0 100644 --- a/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js +++ b/lib/node_modules/@stdlib/number/uint64/base/and/test/test.main.js @@ -83,7 +83,7 @@ tape( 'the function computes the bitwise and of two 64-bit unsigned integers', f }); tape( 'the function computes the bitwise and of two 64-bit unsigned integers (random values)', opts, function test( t ) { - var big64andsum; + var big64and; var expected; var values; var out; @@ -104,8 +104,8 @@ tape( 'the function computes the bitwise and of two 64-bit unsigned integers (ra a = values[ i ]; b = values[ (i+1)%values.length ]; out = and( a, b ); - big64andsum = BigInt.asUintN( 64, a.valueOf() & b.valueOf() ); - expected = new Uint64( big64andsum ); + big64and = BigInt.asUintN( 64, a.valueOf() & b.valueOf() ); + expected = new Uint64( big64and ); t.ok( isEqual( out, expected ), 'returns expected value' ); }