quick question about bit manipulation
I'm pretty new to bit manipulators and I have a quick question. Say I've got a byte set to something like "10110101" and I want to set the the 3rd bit to 0. I know I need to XAND it with the byte "11011111" but I'm not sure of the easiest way to do this in a program. I can't just write:
can I? Is there an easy way to write it simply like this or do I need to calculate out what the base-10 value of 11011111 is and instead XAND it with that? Basically I want to end up writing a function that will set a particular specified bit to zero.
// x is equal to an arbitrary byte and I want to set the third bit to zero
x &= 11011111;
Re: quick question about bit manipulation
11011111 = 255-32 = 223
x&=223; //what you call the 3rd bit is the 5th bit.
thats how i do it. i dont know what vVv is talking about there. I dont think its that complicated.. or did i miss something.