Another way:
c:\@Work\Perl\monks>perl -wMstrict -le "my $x = 0b10001010; my $target = 0b10001101; ;; my $mask = $x ^ $target; ;; my $result = $x ^ $mask; printf qq{0b%b \n}, $result; ;; die qq{target $target != result $result} if $target != $result; " 0b10001101
Give a man a fish: <%-{-{-{-<
In reply to Re: Modifying multiple bits in a byte - bitwise operators
by AnomalousMonk
in thread Modifying multiple bits in a byte - bitwise operators
by stevieb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |