Re: bitwise NOT

2020-01-15 Thread Tom Browder
guys, interesting thread, but it's "complement" -Tom

Re: bitwise NOT

2020-01-14 Thread Todd Chester via perl6-users
On Tue, Jan 14, 2020 at 7:45 AM Paul Procacci > wrote: >> What is the syntax for a twos complement anyway? I'm not sure I understand the question. Two's compliment is +^ ... the routine you've been using. On Tue, Jan 14, 2020 at 12:33 AM

Re: bitwise NOT

2020-01-14 Thread Gerard ONeill
A negative number (-A5) is the twos compliment of the positive number. A ones compliment is all the bits flipped. A twos compliment is a ones compliment plus one. So a ones compliment of (A5) is (-A5 - 1), which is -A6. So presumably, the twos compliment operator is (-). And I suppose for

Re: bitwise NOT

2020-01-14 Thread Paul Procacci
>> What is the syntax for a twos complement anyway? I'm not sure I understand the question. Two's compliment is +^ ... the routine you've been using. On Tue, Jan 14, 2020 at 12:33 AM ToddAndMargo via perl6-users < perl6-us...@perl.org> wrote: > >> On Mon, Jan 13, 2020 at 11:30 PM ToddAndMargo

Re: bitwise NOT

2020-01-13 Thread ToddAndMargo via perl6-users
On Mon, Jan 13, 2020 at 11:30 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Hi All, This works, $ p6 'my uint8 $c = 0xA5; my uint8 $d = +^$c; say $d.base(16);' 5A But this does not: $ p6 'my uint8 $c = 0xA5; say

Re: bitwise NOT

2020-01-13 Thread Paul Procacci
If you read the signature for +^, you'll notice it returns an Int. In your first working example, you're taking a uint8 with binary value 10100101, zero extending it to 64 bits via +^, applying a two's compliment, and then assigning bits [0:7] to another uint8 which at that point contains the

Re: bitwise or?

2018-10-06 Thread JJ Merelo
El sáb., 6 oct. 2018 a las 1:17, Timo Paulssen () escribió: > Yes, there is an absolutely tiny mention of it on the page: > > Metaoperators > > Metaoperators can be parameterized with other operators or subroutines in > the same way as functions can take functions as parameters. To use a >

Re: bitwise or?

2018-10-05 Thread Timo Paulssen
Yes, there is an absolutely tiny mention of it on the page: Metaoperators Metaoperators can be parameterized with other operators or subroutines in the same way as functions can take functions as parameters. To use a subroutine as a parameter, prefix its name with a &. Perl 6 will generate the

Re: bitwise or?

2018-10-05 Thread Trey Harris
On Fri, Oct 5, 2018 at 8:33 AM Timo Paulssen t...@wakelift.de wrote: It's important to point out that inside metaoperators ("composed > operators", "combined operators", ...) the [ ] are just for bracketing > things together — sometimes it's needed to

Re: bitwise paper?

2018-10-05 Thread ToddAndMargo via perl6-users
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 "+&":

Re: bitwise paper?

2018-10-05 Thread David Green
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

Re: bitwise paper?

2018-10-05 Thread David Green
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? Trying to AND 0010 with 0001 $ p6 'my $v = 32 & 16; say $v;' If you search docs.perl6.org for "bitwise" you will find "+&":

Re: bitwise or?

2018-10-05 Thread Timo Paulssen
It's important to point out that inside metaoperators ("composed operators", "combined operators", ...) the [ ] are just for bracketing things together — sometimes it's needed to disambiguate, but you can put it in anyway to make things clearer. This has nothing to do with [+] 1, 2, 3, which is a

Re: bitwise or?

2018-10-05 Thread Brad Gilbert
Note that = is actually a meta operator that can take an infix operator as an argument So $a += 1 is really short for $a [+]= 1 On Fri, Oct 5, 2018 at 1:02 AM Todd Chester wrote: > > > > On 10/4/18 12:13 PM, Brandon Allbery wrote: > > It's fine syntactically, but I think has no

Re: bitwise or?

2018-10-05 Thread Todd Chester
On 10/4/18 12:13 PM, Brandon Allbery wrote: It's fine syntactically, but I think has no effect because it'd be '$v = $v' after the '+|='. Conceivably some future version of rakudo could warn about it having no effect. That explains it. Thank you!

Re: bitwise or?

2018-10-04 Thread Brandon Allbery
It's fine syntactically, but I think has no effect because it'd be '$v = $v' after the '+|='. Conceivably some future version of rakudo could warn about it having no effect. On Thu, Oct 4, 2018 at 3:09 PM ToddAndMargo wrote: > On 10/4/18 12:06 PM, ToddAndMargo wrote: > > On 10/4/18 12:00 PM, JJ

Re: bitwise or?

2018-10-04 Thread ToddAndMargo
On 10/4/18 12:00 PM, JJ Merelo wrote: El jue., 4 oct. 2018 a las 20:58, ToddAndMargo (>) escribió: Hi All, I am trying to come up with something like +=       $ p6 'my $v = 32; $v += 2; say $v;'       34 to replace       $ p6 'my

Re: bitwise or?

2018-10-04 Thread ToddAndMargo
On 10/4/18 12:06 PM, ToddAndMargo wrote: On 10/4/18 12:00 PM, JJ Merelo wrote: El jue., 4 oct. 2018 a las 20:58, ToddAndMargo (>) escribió:     Hi All,     I am trying to come up with something like +=       $ p6 'my $v = 32; $v += 2; say $v;'      

Re: bitwise or?

2018-10-04 Thread ToddAndMargo
On 10/4/18 12:00 PM, Brandon Allbery wrote: You're not doing anything with '$v +| 0b0001'. Were you looking for something like '+|='? (Which I think should work.) On Thu, Oct 4, 2018 at 2:58 PM ToddAndMargo > wrote: Hi All, I am trying to come up

Re: bitwise or?

2018-10-04 Thread JJ Merelo
El jue., 4 oct. 2018 a las 20:58, ToddAndMargo () escribió: > Hi All, > > I am trying to come up with something like += > > $ p6 'my $v = 32; $v += 2; say $v;' > 34 > > to replace > > $ p6 'my $v = 0b0010; $v = $v +| 0b0001; say $v;' > 48 > > > But I obviously have

Re: bitwise or?

2018-10-04 Thread Brandon Allbery
You're not doing anything with '$v +| 0b0001'. Were you looking for something like '+|='? (Which I think should work.) On Thu, Oct 4, 2018 at 2:58 PM ToddAndMargo wrote: > Hi All, > > I am trying to come up with something like += > > $ p6 'my $v = 32; $v += 2; say $v;' > 34 > >

Re: bitwise paper?

2018-10-04 Thread ToddAndMargo
On 10/4/18 10:01 AM, ToddAndMargo wrote: On 10/3/18 7:16 PM, ToddAndMargo wrote: Bitwise "IN" (Does y exist in x): $ 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 p5

Re: bitwise paper?

2018-10-04 Thread ToddAndMargo
On 10/3/18 7:16 PM, ToddAndMargo wrote: Bitwise "IN" (Does y exist in x):     $ 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     p5 not figured out yet $ p5 'my $x =

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
On 10/3/18 7:46 PM, Trey Harris wrote: Assuming you are suggesting your examples are showing differences between the languages, in all your examples of differences between Perl 6 and Perl 5 below, you are using the wrong operator or you changed one of the arguments between the Perl 5 and Perl

Re: bitwise paper?

2018-10-03 Thread Trey Harris
Todd, Assuming you are suggesting your examples are showing differences between the languages, in all your examples of differences between Perl 6 and Perl 5 below, you are using the wrong operator or you changed one of the arguments between the Perl 5 and Perl 6 examples. I won't go through them

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
My keeper file so far: Perl: bitwise operators: alias p5='perl6 -E' alias p6='perl6 -e' Bitwise AND: $ p6 'my $v = 32 +& 16; say $v;' 0 $ p5 'my $v = 32 & 16; say $v;' 0 Bitwise OR: $ p5 'my $v = 32 | 16; say $v;' 48 $ p6 'my $v = 32 +| 16; say $v;' 48

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
> I'm looking at > https://docs.perl6.org/language/operators#index-entry-Numeric_bitwise_AND_operator > right now and it has entries for every bitwise operator. I suggest you > hold down the SHIFT key and press reload to clear your browser cache. > > > > But, now that I know what to look

Re: bitwise paper?

2018-10-03 Thread Trey Harris
On Wed, Oct 3, 2018 at 20:56 ToddAndMargo wrote: > On 10/3/18 1:50 PM, Trey Harris wrote: > > > > On Wed, Oct 3, 2018 at 13:38 ToddAndMargo > > wrote: > > > > > Go to docs.perl6.org > > . Type "bitwise" into

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
On 10/3/18 1:50 PM, Trey Harris wrote: On Wed, Oct 3, 2018 at 13:38 ToddAndMargo > wrote: > Go to docs.perl6.org . Type "bitwise" into the > search box. You will see a popup, "Numeric bitwise AND

Re: bitwise paper?

2018-10-03 Thread Trey Harris
On Wed, Oct 3, 2018 at 13:38 ToddAndMargo wrote: > > Go to docs.perl6.org . Type "bitwise" into the > > search box. You will see a popup, "Numeric bitwise AND operator". Click > > it to be taken to > > >

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
On 10/2/18 9:46 PM, Trey Harris wrote: On Tue, Oct 2, 2018 at 23:57 ToddAndMargo > 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

Re: bitwise paper?

2018-10-03 Thread ToddAndMargo
On 10/2/18 10:16 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? Trying to AND 0010 with 0001 $ p6 'my $v = 32 & 16; say $v;' If you search docs.perl6.org for "bitwise" you will find

Re: bitwise paper?

2018-10-02 Thread David Green
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? Trying to AND 0010 with 0001 $ p6 'my $v = 32 & 16; say $v;' If you search docs.perl6.org for "bitwise" you will find "+&":

Re: bitwise paper?

2018-10-02 Thread Trey Harris
On Tue, Oct 2, 2018 at 23:57 ToddAndMargo 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 with 0001 > > $ p6 'my $v = 32 & 16; say $v;' > all(32, 16) > >

Re: bitwise vttables and ops

2003-07-09 Thread Luke Palmer
Comments welcome, leo PS are there | ^ Perl6 operators too, that do either int or stringwise operations depending on the left operand? No, those are the junction operators (see Quantum::Superpositions), which are going to be fun to write... Luke

Re: bitwise vttables and ops

2003-07-09 Thread Leopold Toetsch
Luke Palmer [EMAIL PROTECTED] wrote: PS are there | ^ Perl6 operators too, that do either int or stringwise operations depending on the left operand? No, those are the junction operators (see Quantum::Superpositions), which are going to be fun to write... A yes, thanks. Forgot about that,

RE: Bitwise operators any(and, are) junctions

2002-11-24 Thread Brent Dax
Simon Cozens: # $a = 2 | 3; # print $a; # # but here's another way of looking at it. Given that we have a # junction of two integers, we look at the zeroth bit of the # junction. If ANY of the zeroth bits in 2 and 3 are set, then # we set the zeroth bit in the result. If ANY of the