On 10/2/18 9:46 PM, Trey Harris wrote:
On Tue, Oct 2, 2018 at 23:57 ToddAndMargo <toddandma...@zoho.com
<mailto:toddandma...@zoho.com>> wrote:
Hi All,
Does anyone know of a paper out in web land showing how to
do bitwise operations? DuckDuckGo give me tons of hits
for Perl 5.
Trying to AND 0010 0000 with 0001 0000
$ p6 'my $v = 32 & 16; say $v;'
all(32, 16)
should give me 0000 0000.
"Should give you"? Why do you say that?
If P6 was asked correctly to do a bitwise AND,
it would give that result. Obviously, it is
not being asked correctly.
Go to docs.perl6.org <http://docs.perl6.org>. Type "bitwise" into the
search box. You will see a popup, "Numeric bitwise AND operator". Click
it to be taken to
https://docs.perl6.org/language/operators#index-entry-Numeric_bitwise_AND_operator,
which will tell you the bitwise AND operator in Perl 6 is +&.
Run the same command with +& and you will get the answer 0.
If, on the other hand, you go to docs.perl6.org <http://docs.perl6.org>,
and type "&" into the search box, you will see under "Infix" (since you
used the operator between two things, it is Infix, as the docs say if
you type "infix" into the search box and click the first entry under
"Reference"; I have no idea how you'd divine that such a thing is called
an infix operator aside from common programming parlance, but if you
have an idea how that might be expressed it can easily be added to the
index) that the first entry is "&".
Click on this "&" and you are taken to https://docs.perl6.org/routine/&
which rather clearly says it returns an all Junction.
So I wonder why were you under the impression that the above "should
give [you] 0000 0000"?
Trey
Thank you.
Looks like I am going to have to look them up one at a time.
The paper I had from Perl 5 had them all in a table. AND, OR, NOR,
NAND, XOR, IN, shift left, shift right, etc..
-T