in reply to How can I set a bit to 0 ?
you "mask" (using & the "bitwise-and") with a bitvector which is only 0 if and only if you want to turn off.
for more see Mask (computing)DB<22> $in = 0b10101010 + + + DB<23> $mask = 0b11110000 # 1 keep 0 erase + + + DB<24> printf "%b", $in & $mask + 10100000
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
|
|---|