You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the Binary Techniques section of the repository, the code example for "Set kth Bit" contains an error. The current code is written as:
num |= (1 >> k);
However, this implementation is incorrect. The correct code should be:
num |= (1 << k);
Issue:
The bit-shift operator is incorrectly specified as >> (right shift) instead of << (left shift). Using >> will shift bits to the right, which does not align with the intended functionality of setting the kth bit. To set the kth bit, we need to shift the bit 1 to the left by k positions.
Expected Behavior:
The code should correctly set the kth bit of the given number num by performing a left shift operation (1 << k) and then using the bitwise OR operator (|=).
The text was updated successfully, but these errors were encountered:
In the Binary Techniques section of the repository, the code example for "Set kth Bit" contains an error. The current code is written as:
However, this implementation is incorrect. The correct code should be:
Issue:
The bit-shift operator is incorrectly specified as >> (right shift) instead of << (left shift). Using >> will shift bits to the right, which does not align with the intended functionality of setting the kth bit. To set the kth bit, we need to shift the bit 1 to the left by k positions.
Expected Behavior:
The code should correctly set the kth bit of the given number num by performing a left shift operation (1 << k) and then using the bitwise OR operator (|=).
The text was updated successfully, but these errors were encountered: