Set the bit at position to 0. Details: perform bitwise and for given number and X. Where X is a number with all the bits - ones and bit on given position - zero. >>> clear_bit(0b10010, 1) # 0b10000 16 >>> clear_bit(0b0, 5) # 0b0 0
(number: int, position: int)
| 22 | |
| 23 | |
| 24 | def clear_bit(number: int, position: int) -> int: |
| 25 | """ |
| 26 | Set the bit at position to 0. |
| 27 | |
| 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. |
| 31 | |
| 32 | >>> clear_bit(0b10010, 1) # 0b10000 |
| 33 | 16 |
| 34 | >>> clear_bit(0b0, 5) # 0b0 |
| 35 | 0 |
| 36 | """ |
| 37 | return number & ~(1 << position) |
| 38 | |
| 39 | |
| 40 | def flip_bit(number: int, position: int) -> int: |
nothing calls this directly
no outgoing calls
no test coverage detected