develooper Front page | perl.fwp | Postings from January 2002

Re: even.pl solutions

Thread Previous | Thread Next
From:
Bart Lateur
Date:
January 29, 2002 01:11
Subject:
Re: even.pl solutions
Message ID:
ejpc5ugu4mpvpppbflpigjkb1eja0697bi@4ax.com
On Mon, 28 Jan 2002 22:05:47 -0500, Rick Myers wrote:

>> > ~$. is odd if $. is even
>> 
>> What is this?  Tell me more, I'm lost.
>
>I didn't get that part myself...

Bitwise "not" will invert all bits, including the lowest one. So this
test for even/odd will return complementary results in this case.

In 2's complement, bitwise not on 1 will return -2, bitwise not on 2
will return -3. The sum is always -1 (all bits set).

-- 
	Bart.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About