Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/algorithms/math/bits/extractBits.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/**
* @param {number, number, number}
* @return {number}
*/

Check failure on line 5 in src/algorithms/math/bits/extractBits.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Trailing spaces not allowed

Check failure on line 6 in src/algorithms/math/bits/extractBits.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Trailing spaces not allowed

Check failure on line 6 in src/algorithms/math/bits/extractBits.js

View workflow job for this annotation

GitHub Actions / test (16.x)

More than 1 blank line not allowed
/* Function to extract 'k' bits from position 'p'

Check failure on line 7 in src/algorithms/math/bits/extractBits.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Expected indentation of 0 spaces but found 1
* and returns the extracted value.
*
*/
export default function extractBits(number, k, p) {
return (((1 << k) - 1) & (number >> (p - 1)));

Check failure on line 12 in src/algorithms/math/bits/extractBits.js

View workflow job for this annotation

GitHub Actions / test (16.x)

Expected indentation of 2 spaces but found 4
}
Loading