On 2020-01-17 20:43, ToddAndMargo via perl6-users wrote:
On Sat, 18 Jan 2020 at 15:03, ToddAndMargo via perl6-users <perl6-us...@perl.org <mailto:perl6-us...@perl.org>> wrote:

    Hi All,

    https://docs.raku.org/routine/+$CIRCUMFLEX_ACCENT

    (Operators) infix +^§

    multi sub infix:<+^>($a, $b --> Int:D)

    Integer bitwise XOR operator: Coerces both arguments to Int and does a
    bitwise XOR (exclusive OR) operation.


    $ p6 'my uint8 $x=0b0101_0111; my uint8 $y = 0b0000_1111; my uint8 $z =
    +^($x, $y ); say "0", $x.base(2); say "0000", $y.base(2); say
    $z.base(2);'

    01010111
    00001111
    11111101


    XOR
    A  B   A xor B
    0  0      0
    1  0      1
    0  1      1
    1  1      0

    That s not what I am seeing above.

    What am I doing wrong this time?

    And who set the high bit making $z negative?

    Many thanks,
    -T


On 2020-01-17 20:15, Kevin Pye wrote:
As you say, +^ is an infix operator. Why are you trying to use it as a function?

Because of the word "sub" in the following
multi sub infix:<+^>($a, $b --> Int:D)



Try $z = $x +^ $y.

$ p6 'my uint8 $x=0b0101_0111; my uint8 $y = 0b0000_1111; my uint8 $z = $x +^ $y; say "0", $x.base(2); say "0000", $y.base(2); say z.base(2);'
===SORRY!=== Error while compiling -e
Undeclared routine:
     z used at line 1


Thank you for the help.



Oops. goof on my part:

$ p6 'my uint8 $x=0b0101_0111; my uint8 $y = 0b0000_1111; my uint8 $z = $x +^ $y; say "0", $x.base(2); say "0000", $y.base(2); say "0",$z.base(2);'
01010111
00001111
01011000

Still don't know what they used the word "sub"

Reply via email to