@@ -8,8 +8,8 @@ def set_bit(number: int, position: int) -> int:
8
8
Set the bit at position to 1.
9
9
10
10
Details: perform bitwise or for given number and X.
11
- Where X is a number with all the bits – zeroes and bit on given
12
- position – one.
11
+ Where X is a number with all the bits - zeroes and bit on given
12
+ position - one.
13
13
14
14
>>> set_bit(0b1101, 1) # 0b1111
15
15
15
@@ -26,8 +26,8 @@ def clear_bit(number: int, position: int) -> int:
26
26
Set the bit at position to 0.
27
27
28
28
Details: perform bitwise and for given number and X.
29
- Where X is a number with all the bits – ones and bit on given
30
- position – zero.
29
+ Where X is a number with all the bits - ones and bit on given
30
+ position - zero.
31
31
32
32
>>> clear_bit(0b10010, 1) # 0b10000
33
33
16
@@ -42,8 +42,8 @@ def flip_bit(number: int, position: int) -> int:
42
42
Flip the bit at position.
43
43
44
44
Details: perform bitwise xor for given number and X.
45
- Where X is a number with all the bits – zeroes and bit on given
46
- position – one.
45
+ Where X is a number with all the bits - zeroes and bit on given
46
+ position - one.
47
47
48
48
>>> flip_bit(0b101, 1) # 0b111
49
49
7
@@ -79,7 +79,7 @@ def get_bit(number: int, position: int) -> int:
79
79
Get the bit at the given position
80
80
81
81
Details: perform bitwise and for the given number and X,
82
- Where X is a number with all the bits – zeroes and bit on given position – one.
82
+ Where X is a number with all the bits - zeroes and bit on given position - one.
83
83
If the result is not equal to 0, then the bit on the given position is 1, else 0.
84
84
85
85
>>> get_bit(0b1010, 0)
0 commit comments