Setting bits through a mask
Erlend
Posts: 612
I know how to read one particular bit out from a Long - and maybe I knew how to set one particular bit in a Long, but I don't any longer - I just get messed up in repeat >>'s and stuff, not very elegant. I feel stupid.
What is the equvalent of bitvalue:= longvalue AND bitmask - when I want to set the bit instead of reading it? Is there a BITSET (longvalue, bitmask, bitvalue)?
This is so embarresing - it is probably there, right under my nose.
Erlend
What is the equvalent of bitvalue:= longvalue AND bitmask - when I want to set the bit instead of reading it? Is there a BITSET (longvalue, bitmask, bitvalue)?
This is so embarresing - it is probably there, right under my nose.
Erlend
Comments
BTW, the parens are unnecessary for the compiler; they just make the order of operation clearer to us humans.
-Phil
By passing a value instead of a pointer, I can modify a variable like this:
or update a different variable with a modification
(and there is no smirk-smirk here, like in there are in so many other forums)
Erlend
btw, checking out method 1 brought me back to the days of Karnough diagrams...