Flip the bit at position. Details: perform bitwise xor for given number and X. Where X is a number with all the bits - zeroes and bit on given position - one. >>> flip_bit(0b101, 1) # 0b111 7 >>> flip_bit(0b101, 0) # 0b100 4
(number: int, position: int)
| 38 | |
| 39 | |
| 40 | def flip_bit(number: int, position: int) -> int: |
| 41 | """ |
| 42 | Flip the bit at position. |
| 43 | |
| 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. |
| 47 | |
| 48 | >>> flip_bit(0b101, 1) # 0b111 |
| 49 | 7 |
| 50 | >>> flip_bit(0b101, 0) # 0b100 |
| 51 | 4 |
| 52 | """ |
| 53 | return number ^ (1 << position) |
| 54 | |
| 55 | |
| 56 | def is_bit_set(number: int, position: int) -> bool: |
nothing calls this directly
no outgoing calls
no test coverage detected