I would like to know how to delete bits in a bit value.
I receive a 10 bits value (bit 0 to bit 9) and I have to send a variable which ignore bit 0, bit 2, bit 4 and bit 6 of the received value then my variable will be : bit 987531. How can I do ? I heard about mask bit I don't really know how to use it even if I know the mask would be 0x55
Thank you for helping me
A solution that always uses 5 bits could be
But here is another solution that instead of using a fixed number of bits (i.e. 5 in your case) uses a function that allows you to specify the number of bits to keep.
It could be something like:
will output:
Changing
mainto request 3 instead of 5 bits, like:will output: