Skip to content

Commit 144b269

Browse files
committed
Added better comments to the function
1 parent 111012b commit 144b269

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

bit_manipulation/single_bit_manipulation_operations.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,19 @@ def clear_least_significant_set_bit(number: int) -> int:
9797
"""
9898
Clear the least significant set bit.
9999
100-
Details: perform bitwise and for given number and X.
101-
Where X is a number with all the bits - ones and bit on given
102-
position - zero.
100+
Details: perform bitwise operation for the given number X.
101+
Where X is in bits, and the least significant set, i.e., the rightmost 1, is cleared.
103102
104103
>>> clear_least_significant_set_bit(0b1101) # 0b1100
105104
12
106105
>>> clear_least_significant_set_bit(0b1111) # 0b1110
107106
14
107+
>>> clear_least_significant_set_bit(0b1100) # 0b1000
108+
8
109+
>>> clear_least_significant_set_bit(0b0) # 0b0
110+
0
111+
>>> clear_least_significant_set_bit(0b1) # 0b0
112+
0
108113
"""
109114
return number & (number - 1)
110115

0 commit comments

Comments
 (0)