On Mon, Jan 20, 2020 at 3:57 PM ToddAndMargo via perl6-users <perl6-users@perl.org <mailto:perl6-users@perl.org>> wrote:

    Hi All,

    Now what am I doing wrong?

          my $v = 0b00101101 ^ 0b00001001; say $v.base(2);
          one(101101, 1001)

    It should be
          100100


    Many thanks,
    -T


On 2020-01-20 14:21, Brad Gilbert wrote:
Why would you think that?

The numeric binary xor operator is +^.

     my $v = 0b00101101 +^ 0b00001001; say $v.base(2);
     # 100100

^ is the junctive xor operator.

    my $v = 1 ^ 2 ^ 'a';
   $v eq 'a'; # True
   $v == 1; # True
   $v == 2; # True
   $v == 3; # False

There is also the stringy binary xor operator.

     say 'A' ~^ '%'; # D

Ah poop!  I forgot the +

Thanks for the second pair of eye!

Much better:
    my $v = 0b00101101 +^ 0b00001001; say $v.base(2);
    100100

Reply via email to