In C I could, for example, zero out bit #10 in a 32-bit unsigned value like so:

```
unsigned long value = 0xdeadbeef;
value &= ~(1<<10);
```

How do I do that in Python?

Login

0 votes

For manipulating the bits, there is a special kind of sets of bitwise operators in Python like

Consider the below example :

To perform left shift in python be careful as Python integers aren't fixed-width so we have to use bit masks to obtain the low order bits.

(B << 5) & 0xffffffff