![]() |
|
Keep It Simple, Stupid | |
PerlMonks |
Re: How can I set a bit to 0 ?by harangzsolt33 (Chaplain) |
on May 28, 2022 at 02:19 UTC ( #11144242=note: print w/replies, xml ) | Need Help?? |
The XOR operator works just like the bitwise NOT operator (~) because it flips bits, but it takes two inputs. Input number 1 determines which bits will be negated in input number 2:
For example, 0000 ^ 0000 will simply leave all the bits zero.
The AND operator turns specific bits OFF. It takes two input numbers. The bits in input number 1 determine which bits in input number will be turned off. The ones that are zero will be turned off. Here is an example: 1001 ^ 0110 = 0000
See, this is really simple. Here is a tiny example program:
In Section
Seekers of Perl Wisdom
|
|