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 ToddAndMargo

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 consi

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 v

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 (+^$c).base(16);'

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 bin