From c4fae1c78ee6f9507542dccd928fd5de4f402887 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Wed, 27 Mar 2024 00:14:24 +0530 Subject: [PATCH 01/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../uint32/base/from-binary-string/README.md | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md index b5487dc4c3e2..ff5e3b10dcdf 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md @@ -59,6 +59,7 @@ val = fromBinaryStringUint32( bstr );
## Examples +Here are some examples demonstrating the usage of the fromBinaryStringUint32 function: @@ -69,18 +70,24 @@ var MAX_UINT = require( '@stdlib/constants/uint32/max' ); var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); var fromBinaryStringUint32 = require( '@stdlib/number/uint32/base/from-binary-string' ); -var b; -var x; -var y; -var i; - -// Convert random integers to literal bit representations and then convert them back... -for ( i = 0; i < 100; i++ ) { - x = round( randu()*MAX_UINT ); - b = toBinaryStringUint32( x ); - y = fromBinaryStringUint32( b ); - console.log( '%d => %s => %d', x, b, y ); +// Example 1: Convert a binary string representing an integer to a 32-bit unsigned integer +var binaryString = '10101010101010101010101010101010'; +var result = fromBinaryStringUint32( binaryString ); +// returns 2863311530 + + +// Example 2: Convert random integers to binary strings and then back to integers +var round = require( '@stdlib/math/base/special/round' ); +var MAX_UINT = require( '@stdlib/constants/uint32/max' ); +var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); + +for ( var i = 0; i < 5; i++ ) { + var x = round( randu * MAX_UINT ); + var b = toBinaryStringUint32( x ); + var y = fromBinaryStringUint32( y ); + console.log( '%d => %s => %d', x, b, y); } + ```
From 669cf6855171b4c572b6b930906ae7a367f9cbaa Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:31:37 +0530 Subject: [PATCH 02/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/rotl/README.md | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md b/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md index 8cbb29d4b170..4ce6abc86c3a 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md @@ -83,27 +83,33 @@ bstr = toBinaryStringUint32( y ); ```javascript -var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); -var MAX_INT = require( '@stdlib/constants/uint32/max' ); -var rotl32 = require( '@stdlib/number/uint32/base/rotl' ); +var toBinaryStringUint32 = require('@stdlib/number/uint32/base/to-binary-string'); +var MAX_UINT = require('@stdlib/constants/uint32/max'); +var rotl32 = require('@stdlib/number/uint32/base/rotl'); -var HALF; var x; var y; -var i; -for ( i = 0; i < 100; i++ ) { +// Example 1: Rotate integers to the left and display their binary representations +for (var i = 0; i < 100; i++) { x = i; - y = rotl32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); + y = rotl32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } -HALF = (MAX_INT+1) / 2; -for ( i = 0; i < 100; i++ ) { +// Example 2: Rotate integers in the second half of the range to the left and display their binary representations +var HALF = (MAX_UINT + 1) / 2; +for (var i = 0; i < 100; i++) { x = HALF + i; - y = rotl32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); + y = rotl32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } + +// Example 3: Rotate a specific integer and display its binary representation +var specificInteger = 123456; +var rotationAmount = 5; +var rotatedInteger = rotl32(specificInteger, rotationAmount); +console.log('%d => %d: %s => %s', specificInteger, rotationAmount, toBinaryStringUint32(specificInteger), toBinaryStringUint32(rotatedInteger)); ``` From f3e6506b118149650dfd536fcb3bbdddce1d27ac Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:36:58 +0530 Subject: [PATCH 03/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/rotr/README.md | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md b/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md index 3df31fd9cca5..2f444b4adaf0 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 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. @@ -83,27 +83,35 @@ bstr = toBinaryStringUint32( y ); ```javascript -var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); -var MAX_INT = require( '@stdlib/constants/uint32/max' ); -var rotr32 = require( '@stdlib/number/uint32/base/rotr' ); +var toBinaryStringUint32 = require('@stdlib/number/uint32/base/to-binary-string'); +var MAX_UINT = require('@stdlib/constants/uint32/max'); +var rotr32 = require('@stdlib/number/uint32/base/rotr'); -var HALF; var x; var y; -var i; +var rotationAmount; -for ( i = 0; i < 100; i++ ) { +// Example 1: Rotate integers to the right and display their binary representations +for (var i = 0; i < 100; i++) { x = i; - y = rotr32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); + y = rotr32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } -HALF = (MAX_INT+1) / 2; -for ( i = 0; i < 100; i++ ) { +// Example 2: Rotate integers in the second half of the range to the right and display their binary representations +var HALF = (MAX_UINT + 1) / 2; +for (var i = 0; i < 100; i++) { x = HALF + i; - y = rotr32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); + y = rotr32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } + +// Example 3: Rotate a specific integer to the right and display its binary representation +var x = 123456; +var rotationAmount = 5; +var y = rotr32(x, rotationAmount); +console.log('%d => %d : %s => %s', x, rotationAmount, toBinaryStringUint32(x), toBinaryStringUint32(y)); + ``` From 10a442f6d7c847e1bca5a57ba6e5993b16b380d8 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:38:20 +0530 Subject: [PATCH 04/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/rotl/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md b/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md index 4ce6abc86c3a..1678e7fb8bc5 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/rotl/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 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. @@ -89,7 +89,7 @@ var rotl32 = require('@stdlib/number/uint32/base/rotl'); var x; var y; - +var rotationAmount; // Example 1: Rotate integers to the left and display their binary representations for (var i = 0; i < 100; i++) { x = i; @@ -106,10 +106,10 @@ for (var i = 0; i < 100; i++) { } // Example 3: Rotate a specific integer and display its binary representation -var specificInteger = 123456; +var x = 123456; var rotationAmount = 5; -var rotatedInteger = rotl32(specificInteger, rotationAmount); -console.log('%d => %d: %s => %s', specificInteger, rotationAmount, toBinaryStringUint32(specificInteger), toBinaryStringUint32(rotatedInteger)); +var y = rotl32(x, rotationAmount); +console.log('%d => %d: %s => %s', x, rotationAmount, toBinaryStringUint32(x), toBinaryStringUint32(y)); ``` From 603335c4e6378a65ab126bb89ce5ad231b9bf585 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:43:20 +0530 Subject: [PATCH 05/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../uint32/base/to-binary-string/README.md | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md index 5aeb8078bfcb..2f1e80401cec 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 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. @@ -84,28 +84,37 @@ str = toBinaryString( a[2] ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var toBinaryString = require( '@stdlib/number/uint32/base/to-binary-string' ); +var randu = require('@stdlib/random/base/randu'); +var round = require('@stdlib/math/base/special/round'); +var Uint32Array = require('@stdlib/array/uint32'); +var toBinaryString = require('@stdlib/number/uint32/base/to-binary-string'); var x; var y; var b; -var i; +var specificIntegers; +//Example 1: Generate random unsigned 32-bit integers and convert them to literal bit representations +var numberOfIntegers = 100; +var integers = new Uint32Array(numberOfIntegers); -// Generate random unsigned 32-bit integers... -x = new Uint32Array( 100 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*1.0e5 ); +for (var i = 0; i < numberOfIntegers; i++) { + integers[i] = round(randu() * 1.0e5); } -// Convert unsigned 32-bit integers to literal bit representations... -for ( i = 0; i < x.length; i++ ) { - b = toBinaryString( x[i] ); - y = parseInt( b, 2 ); - console.log( 'x: %d, b: %s, y: %d', x[i], b, y ); +for (var i = 0; i < numberOfIntegers; i++) { + b = toBinaryString(integers[i]); + y = parseInt(b, 2); + console.log('Integer: %d, Binary Representation: %s, Parsed Integer: %d', integers[i], b, y); } + +//Example 2: Convert specific integers to literal bit representations +specificIntegers = [123, 456, 789, 1024]; +for (var i = 0; i < specificIntegers.length; i++) { + b = toBinaryString(specificIntegers[i]); + y = parseInt(b, 2); + console.log('%d => %s => %d', specificIntegers[i], b, y); +} + ``` From 03aed0f59f9cacf6d8108b6d4171b7d1fccccdfc Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:48:46 +0530 Subject: [PATCH 06/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../number/uint32/base/to-int32/README.md | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md b/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md index 8bfc446ae61e..66ed0440eb41 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 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. @@ -55,23 +55,30 @@ y = uint32ToInt32( float64ToUint32( 3 ) ); ```javascript -var randu = require( '@stdlib/random/base/randu' ); -var MAX_UINT32 = require( '@stdlib/constants/uint32/max' ); -var float64ToUint32 = require( '@stdlib/number/float64/base/to-uint32' ); -var uint32ToInt32 = require( '@stdlib/number/uint32/base/to-int32' ); +var randu = require('@stdlib/random/base/randu'); +var MAX_UINT32 = require('@stdlib/constants/uint32/max'); +var float64ToUint32 = require('@stdlib/number/float64/base/to-uint32'); +var uint32ToInt32 = require('@stdlib/number/uint32/base/to-int32'); var uint32; var int32; -var i; - -for ( i = 0; i < 100; i++ ) { +var uint32_array +// Example: Generate a random unsigned 32-bit integer and convert it to a signed 32-bit integer +for (var i = 0; i < 100; i++) { // Generate a random unsigned 32-bit integer: - uint32 = float64ToUint32( randu()*MAX_UINT32 ); + uint32 = float64ToUint32(randu() * MAX_UINT32); // Convert the unsigned integer to a signed 32-bit integer: - int32 = uint32ToInt32( uint32 ); + int32 = uint32ToInt32(uint32); + console.log('uint32: %d => int32: %d', uint32, int32); +} - console.log( 'uint32: %d => int32: %d', uint32, int32 ); +// Additional Example: Convert specific unsigned 32-bit integers to signed 32-bit integers +uint32_array = [4294967295, 3, 1000000]; +for (var i = 0; i < specificValues.length; i++) { + uint32 = specificValues[i]; + int32 = uint32ToInt32(uint32); + console.log('uint32: %d => int32: %d', uint32, int32); } ``` From 63315e2d1ca2d07a4345576f2f9e552f3cf122fe Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:50:09 +0530 Subject: [PATCH 07/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/from-binary-string/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md index ff5e3b10dcdf..f88916b65c69 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2018 The Stdlib Authors. +Copyright (c) 2024 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. @@ -75,7 +75,6 @@ var binaryString = '10101010101010101010101010101010'; var result = fromBinaryStringUint32( binaryString ); // returns 2863311530 - // Example 2: Convert random integers to binary strings and then back to integers var round = require( '@stdlib/math/base/special/round' ); var MAX_UINT = require( '@stdlib/constants/uint32/max' ); @@ -87,7 +86,6 @@ for ( var i = 0; i < 5; i++ ) { var y = fromBinaryStringUint32( y ); console.log( '%d => %s => %d', x, b, y); } - ``` From 90878270cce14295e35758d2de4f2fda14b00036 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:52:26 +0530 Subject: [PATCH 08/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../uint32/base/from-binary-string/README.md | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md index f88916b65c69..c79c6ade9ef3 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/README.md @@ -70,20 +70,21 @@ var MAX_UINT = require( '@stdlib/constants/uint32/max' ); var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); var fromBinaryStringUint32 = require( '@stdlib/number/uint32/base/from-binary-string' ); +var x; +var y; +var b; + // Example 1: Convert a binary string representing an integer to a 32-bit unsigned integer -var binaryString = '10101010101010101010101010101010'; -var result = fromBinaryStringUint32( binaryString ); +b = '10101010101010101010101010101010'; +y = fromBinaryStringUint32( binaryString ); // returns 2863311530 // Example 2: Convert random integers to binary strings and then back to integers -var round = require( '@stdlib/math/base/special/round' ); -var MAX_UINT = require( '@stdlib/constants/uint32/max' ); -var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); for ( var i = 0; i < 5; i++ ) { - var x = round( randu * MAX_UINT ); - var b = toBinaryStringUint32( x ); - var y = fromBinaryStringUint32( y ); + x = round( randu * MAX_UINT ); + b = toBinaryStringUint32( x ); + y = fromBinaryStringUint32( y ); console.log( '%d => %s => %d', x, b, y); } ``` From 0f92ebc2c9e48964e709c7e046ead7e61ffcb0f5 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:52:48 +0530 Subject: [PATCH 09/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../base/from-binary-string/examples/index.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/examples/index.js index 71aaa9c80fe0..32fa4111cfa1 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/from-binary-string/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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. @@ -22,17 +22,22 @@ var randu = require( '@stdlib/random/base/randu' ); var round = require( '@stdlib/math/base/special/round' ); var MAX_UINT = require( '@stdlib/constants/uint32/max' ); var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); -var fromBinaryStringUint32 = require( './../lib' ); +var fromBinaryStringUint32 = require( '@stdlib/number/uint32/base/from-binary-string' ); -var b; var x; var y; -var i; +var b; + +// Example 1: Convert a binary string representing an integer to a 32-bit unsigned integer +b = '10101010101010101010101010101010'; +y = fromBinaryStringUint32( binaryString ); +// returns 2863311530 + +// Example 2: Convert random integers to binary strings and then back to integers -// Convert random integers to literal bit representations and then convert them back... -for ( i = 0; i < 100; i++ ) { - x = round( randu()*MAX_UINT ); - b = toBinaryStringUint32( x ); - y = fromBinaryStringUint32( b ); - console.log( '%d => %s => %d', x, b, y ); +for ( var i = 0; i < 5; i++ ) { + x = round( randu * MAX_UINT ); + b = toBinaryStringUint32( x ); + y = fromBinaryStringUint32( y ); + console.log( '%d => %s => %d', x, b, y); } From 4e084f653b4d66e59e0f6bebb3ddfb86e98eb0d0 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:53:26 +0530 Subject: [PATCH 10/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../number/uint32/base/rotl/examples/index.js | 36 +++++++++++-------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js index 7b9fbd3fd6e1..433d3128e30a 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js @@ -18,24 +18,30 @@ 'use strict'; -var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); -var MAX_INT = require( '@stdlib/constants/uint32/max' ); -var rotl32 = require( './../lib' ); +var toBinaryStringUint32 = require('@stdlib/number/uint32/base/to-binary-string'); +var MAX_UINT = require('@stdlib/constants/uint32/max'); +var rotl32 = require('@stdlib/number/uint32/base/rotl'); -var HALF; var x; var y; -var i; - -for ( i = 0; i < 100; i++ ) { - x = i; - y = rotl32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); +var rotationAmount; +// Example 1: Rotate integers to the left and display their binary representations +for (var i = 0; i < 100; i++) { + x = i; + y = rotl32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } -HALF = (MAX_INT+1) / 2; -for ( i = 0; i < 100; i++ ) { - x = HALF + i; - y = rotl32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); +// Example 2: Rotate integers in the second half of the range to the left and display their binary representations +var HALF = (MAX_UINT + 1) / 2; +for (var i = 0; i < 100; i++) { + x = HALF + i; + y = rotl32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } + +// Example 3: Rotate a specific integer and display its binary representation +var x = 123456; +var rotationAmount = 5; +var y = rotl32(x, rotationAmount); +console.log('%d => %d: %s => %s', x, rotationAmount, toBinaryStringUint32(x), toBinaryStringUint32(y)); From 7dccf77b56d73bae5b65a72447aaf119c117f8a5 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:53:58 +0530 Subject: [PATCH 11/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- lib/node_modules/@stdlib/number/uint32/base/rotr/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md b/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md index 2f444b4adaf0..0c7ca16ab438 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/rotr/README.md @@ -111,7 +111,6 @@ var x = 123456; var rotationAmount = 5; var y = rotr32(x, rotationAmount); console.log('%d => %d : %s => %s', x, rotationAmount, toBinaryStringUint32(x), toBinaryStringUint32(y)); - ``` From f8934392a2ebd5948a086c618c4052fe6125ee39 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:54:16 +0530 Subject: [PATCH 12/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/rotl/examples/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js index 433d3128e30a..6f853ced5ae8 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/rotl/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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. From e61ce5b5c215b5db98db5cc9ef96221511fcf172 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:54:36 +0530 Subject: [PATCH 13/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../number/uint32/base/rotr/examples/index.js | 37 +++++++++++-------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/rotr/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/rotr/examples/index.js index 1fb8b0af8ee6..a7bfcc09144c 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/rotr/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/rotr/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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. @@ -18,24 +18,31 @@ 'use strict'; -var toBinaryStringUint32 = require( '@stdlib/number/uint32/base/to-binary-string' ); -var MAX_INT = require( '@stdlib/constants/uint32/max' ); -var rotr32 = require( './../lib' ); +var toBinaryStringUint32 = require('@stdlib/number/uint32/base/to-binary-string'); +var MAX_UINT = require('@stdlib/constants/uint32/max'); +var rotr32 = require('@stdlib/number/uint32/base/rotr'); -var HALF; var x; var y; -var i; +var rotationAmount; -for ( i = 0; i < 100; i++ ) { - x = i; - y = rotr32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); +// Example 1: Rotate integers to the right and display their binary representations +for (var i = 0; i < 100; i++) { + x = i; + y = rotr32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } -HALF = (MAX_INT+1) / 2; -for ( i = 0; i < 100; i++ ) { - x = HALF + i; - y = rotr32( x, 10 ); - console.log( '%d => %s => %s => %d', x, toBinaryStringUint32( x ), toBinaryStringUint32( y ), y ); +// Example 2: Rotate integers in the second half of the range to the right and display their binary representations +var HALF = (MAX_UINT + 1) / 2; +for (var i = 0; i < 100; i++) { + x = HALF + i; + y = rotr32(x, 10); + console.log('%d => %s => %s => %d', x, toBinaryStringUint32(x), toBinaryStringUint32(y), y); } + +// Example 3: Rotate a specific integer to the right and display its binary representation +var x = 123456; +var rotationAmount = 5; +var y = rotr32(x, rotationAmount); +console.log('%d => %d : %s => %s', x, rotationAmount, toBinaryStringUint32(x), toBinaryStringUint32(y)); From 540122321ea99ccca25ce8963ac02384558bbac6 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:55:22 +0530 Subject: [PATCH 14/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/to-binary-string/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md index 2f1e80401cec..984e3e274265 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/README.md @@ -93,7 +93,8 @@ var x; var y; var b; var specificIntegers; -//Example 1: Generate random unsigned 32-bit integers and convert them to literal bit representations + +// Example 1: Generate random unsigned 32-bit integers and convert them to literal bit representations var numberOfIntegers = 100; var integers = new Uint32Array(numberOfIntegers); @@ -107,14 +108,13 @@ for (var i = 0; i < numberOfIntegers; i++) { console.log('Integer: %d, Binary Representation: %s, Parsed Integer: %d', integers[i], b, y); } -//Example 2: Convert specific integers to literal bit representations +// Example 2: Convert specific integers to literal bit representations specificIntegers = [123, 456, 789, 1024]; for (var i = 0; i < specificIntegers.length; i++) { b = toBinaryString(specificIntegers[i]); y = parseInt(b, 2); console.log('%d => %s => %d', specificIntegers[i], b, y); } - ``` From 6b36f8fdd337fbf8b7c65bc903698e13f92bcf3a Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:55:58 +0530 Subject: [PATCH 15/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../base/to-binary-string/examples/index.js | 39 ++++++++++++------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/examples/index.js index 64aeb747854d..1b36a76d580f 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/to-binary-string/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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. @@ -18,25 +18,34 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var Uint32Array = require( '@stdlib/array/uint32' ); -var toBinaryString = require( './../lib' ); +var randu = require('@stdlib/random/base/randu'); +var round = require('@stdlib/math/base/special/round'); +var Uint32Array = require('@stdlib/array/uint32'); +var toBinaryString = require('@stdlib/number/uint32/base/to-binary-string'); var x; var y; var b; -var i; +var specificIntegers; -// Generate random unsigned 32-bit integers... -x = new Uint32Array( 100 ); -for ( i = 0; i < x.length; i++ ) { - x[ i ] = round( randu()*1.0e5 ); +// Example 1: Generate random unsigned 32-bit integers and convert them to literal bit representations +var numberOfIntegers = 100; +var integers = new Uint32Array(numberOfIntegers); + +for (var i = 0; i < numberOfIntegers; i++) { + integers[i] = round(randu() * 1.0e5); +} + +for (var i = 0; i < numberOfIntegers; i++) { + b = toBinaryString(integers[i]); + y = parseInt(b, 2); + console.log('Integer: %d, Binary Representation: %s, Parsed Integer: %d', integers[i], b, y); } -// Convert unsigned 32-bit integers to literal bit representations... -for ( i = 0; i < x.length; i++ ) { - b = toBinaryString( x[i] ); - y = parseInt( b, 2 ); - console.log( 'x: %d, b: %s, y: %d', x[i], b, y ); +// Example 2: Convert specific integers to literal bit representations +specificIntegers = [123, 456, 789, 1024]; +for (var i = 0; i < specificIntegers.length; i++) { + b = toBinaryString(specificIntegers[i]); + y = parseInt(b, 2); + console.log('%d => %s => %d', specificIntegers[i], b, y); } From c6335bc0f072a0cf97eba2c51e208bde5b3ae2f3 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:56:48 +0530 Subject: [PATCH 16/17] Update README.md Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../@stdlib/number/uint32/base/to-int32/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md b/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md index 66ed0440eb41..a5e91711cfb7 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md +++ b/lib/node_modules/@stdlib/number/uint32/base/to-int32/README.md @@ -63,7 +63,7 @@ var uint32ToInt32 = require('@stdlib/number/uint32/base/to-int32'); var uint32; var int32; var uint32_array -// Example: Generate a random unsigned 32-bit integer and convert it to a signed 32-bit integer +// Example1 : Generate a random unsigned 32-bit integer and convert it to a signed 32-bit integer for (var i = 0; i < 100; i++) { // Generate a random unsigned 32-bit integer: uint32 = float64ToUint32(randu() * MAX_UINT32); @@ -73,7 +73,7 @@ for (var i = 0; i < 100; i++) { console.log('uint32: %d => int32: %d', uint32, int32); } -// Additional Example: Convert specific unsigned 32-bit integers to signed 32-bit integers +// Example2: Convert specific unsigned 32-bit integers to signed 32-bit integers uint32_array = [4294967295, 3, 1000000]; for (var i = 0; i < specificValues.length; i++) { uint32 = specificValues[i]; From d6402319cfbd3923dbc1a19060ba3d40b0c99474 Mon Sep 17 00:00:00 2001 From: Aman Morghade <136126298+xaman27x@users.noreply.github.com> Date: Sun, 31 Mar 2024 00:57:22 +0530 Subject: [PATCH 17/17] Update index.js Signed-off-by: Aman Morghade <136126298+xaman27x@users.noreply.github.com> --- .../uint32/base/to-int32/examples/index.js | 33 +++++++++++-------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/node_modules/@stdlib/number/uint32/base/to-int32/examples/index.js b/lib/node_modules/@stdlib/number/uint32/base/to-int32/examples/index.js index 1fbf5fe79d49..a6fa5004b16c 100644 --- a/lib/node_modules/@stdlib/number/uint32/base/to-int32/examples/index.js +++ b/lib/node_modules/@stdlib/number/uint32/base/to-int32/examples/index.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2018 The Stdlib Authors. +* Copyright (c) 2024 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. @@ -18,21 +18,28 @@ 'use strict'; -var randu = require( '@stdlib/random/base/randu' ); -var MAX_UINT32 = require( '@stdlib/constants/uint32/max' ); -var float64ToUint32 = require( '@stdlib/number/float64/base/to-uint32' ); -var uint32ToInt32 = require( './../lib' ); +var randu = require('@stdlib/random/base/randu'); +var MAX_UINT32 = require('@stdlib/constants/uint32/max'); +var float64ToUint32 = require('@stdlib/number/float64/base/to-uint32'); +var uint32ToInt32 = require('@stdlib/number/uint32/base/to-int32'); var uint32; var int32; -var i; +var uint32_array +// Example1 : Generate a random unsigned 32-bit integer and convert it to a signed 32-bit integer +for (var i = 0; i < 100; i++) { + // Generate a random unsigned 32-bit integer: + uint32 = float64ToUint32(randu() * MAX_UINT32); -for ( i = 0; i < 100; i++ ) { - // Generate a random unsigned 32-bit integer: - uint32 = float64ToUint32( randu()*MAX_UINT32 ); - - // Convert the unsigned integer to a signed 32-bit integer: - int32 = uint32ToInt32( uint32 ); + // Convert the unsigned integer to a signed 32-bit integer: + int32 = uint32ToInt32(uint32); + console.log('uint32: %d => int32: %d', uint32, int32); +} - console.log( 'uint32: %d => int32: %d', uint32, int32 ); +// Example2: Convert specific unsigned 32-bit integers to signed 32-bit integers +uint32_array = [4294967295, 3, 1000000]; +for (var i = 0; i < specificValues.length; i++) { + uint32 = specificValues[i]; + int32 = uint32ToInt32(uint32); + console.log('uint32: %d => int32: %d', uint32, int32); }