On 10/2/18 9:15 PM, David Green wrote:
On 2018-10-02 9:57 pm, ToddAndMargo wrote:
Does anyone know of a paper out in web land showing how to do bitwise
operations?
$ p6 'my $v = 32 & 16; say $v;'
If you search docs.perl6.org for "bitwise" you will find "+&":
https://docs.perl6.org/language/operators#infix_+&
And sure enough, 'say 32 +& 16' will return '0'.
The other bitwise operators work likewise: almost the same as Perl 5,
but with a "+" in front (to indicate that they are numeric operators, as
opposed to plain "&", "|", etc., which are now junctions... and yes,
there is https://docs.perl6.org/type/Junction for those who dare!).
-David
P.S. Actually, the search returns:
https://docs.perl6.org/language/operators#index-entry-Numeric_bitwise_AND_operator
...instead of the correct fragment: "#infix_+&"
Hi Brad,
Thank you. I did find that. I was hoping to find them all in the
same place, but instead kept searching until I found the ones
I use. I posted them somewhere else in this thread.
Did I miss a pattern test?
$ p6 'my $x=0b1001; my $y=0b0101; my $z=$x +& $y; say so $y == $z;'
False
$ p6 'my $x=0b1001; my $y=0b1001; my $z=$x +& $y; say so $y == $z;'
True
It is an easy sub to write, if not.
-T