This commit is contained in:
Ujjwal Aryal 2024-07-17 10:36:19 +09:00 committed by GitHub
commit bbb86202fc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -0,0 +1,13 @@
/**
* @param {number, number, number}
* @return {number}
*/
/* Function to extract 'k' bits from position 'p'
* and returns the extracted value.
*
*/
export default function extractBits(number, k, p) {
return (((1 << k) - 1) & (number >> (p - 1)));
}