mirror of
https://github.com/trekhleb/javascript-algorithms.git
synced 2025-07-15 08:32:24 +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
@ -2,12 +2,7 @@
|
||||
|
||||
#### Get Bit
|
||||
|
||||
This method shifts `1` over by `bitPosition` bits, creating a
|
||||
value that looks like `00100`. Then we perform `AND` operation
|
||||
that clears all bits from the original number except the
|
||||
`bitPosition` one. Then we compare the result with zero. If
|
||||
result is zero that would mean that original number has `0` at
|
||||
position `bitPosition`.
|
||||
This method shifts the relevant bit to the zeroth position. Then we perform 'AND' operation with one which has bit pattern like '00001'. This clears all bits from the original number except the relevant one. If the relevant bit is one, the result is '1', otherwise the result is '0'.
|
||||
|
||||
> See `getBit` function for further details.
|
||||
|
||||
|
Reference in New Issue
Block a user