mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-12-19 08:59:05 +08:00
Minor fixes. (#91)
* Get Bit: Make more terse * Power of two: Allowed 1 as a valid power of 2. Power of two: Removed unnecessary exception throwing. * Fisher Yates: Made more terse * Least Common Multiple: Fill undefined value * Greatest Common Divisor: Fill undefined value. Greatest Common Divisor: Make more terse.
This commit is contained in:
committed by
Oleksii Trekhleb
parent
93bfe97e27
commit
e36c441fa9
@@ -4,5 +4,5 @@
|
||||
* @return {number}
|
||||
*/
|
||||
export default function getBit(number, bitPosition) {
|
||||
return (number & (1 << bitPosition)) === 0 ? 0 : 1;
|
||||
return (number >> bitPosition) & 1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user