Set the bit at position to 1. Details: perform bitwise or for given number and X. Where X is a number with all the bits - zeroes and bit on given position - one. >>> set_bit(0b1101, 1) # 0b1111 15 >>> set_bit(0b0, 5) # 0b100000 32 >>> set_bit(0b1111, 1) # 0b111
(number: int, position: int)
| 4 | |
| 5 | |
| 6 | def set_bit(number: int, position: int) -> int: |
| 7 | """ |
| 8 | Set the bit at position to 1. |
| 9 | |
| 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. |
| 13 | |
| 14 | >>> set_bit(0b1101, 1) # 0b1111 |
| 15 | 15 |
| 16 | >>> set_bit(0b0, 5) # 0b100000 |
| 17 | 32 |
| 18 | >>> set_bit(0b1111, 1) # 0b1111 |
| 19 | 15 |
| 20 | """ |
| 21 | return number | (1 << position) |
| 22 | |
| 23 | |
| 24 | def clear_bit(number: int, position: int) -> int: |
nothing calls this directly
no outgoing calls
no test coverage detected