Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: Bit operations for beginners

by liz (Monsignor)
on Aug 08, 2003 at 15:16 UTC ( #282213=note: print w/ replies, xml ) Need Help??


in reply to Bit operations for beginners

I think the truth table for "The ^ operator" is wrong. I think it should be:

Bit 0Bit 1Bit 0 ^ Bit 1
000
011
101
110

Also: "&&" works by evaluating the right operand, and if and only if that returns a true value the left operand is evaluated and that result is returned. "||" works similar, but only evaluates the left operand if the right operand was false.

This is incorrect. Perl always works from left to right. See:

$a = 0; $b = 0; $c = $a++ && $b++; # only $a++ is evaluated print "a = $a, b = $b\n"; # prints "a = 1, b = 0"
And:
$a = 0; $b = 0; $c = ++$a || ++$b; # only ++$a is evaluated print "a = $a, b = $b\n"; # prints "a = 1, b = 0"
Otherwise I think this can go to Tutorials as well...

Liz


Comment on Re: Bit operations for beginners
Select or Download Code
Re: Re: Bit operations for beginners
by Cine (Friar) on Aug 09, 2003 at 10:09 UTC
    Ups :( I even proofread it 5-6 times... Remember, always have someone else proofread it too...

    T I M T O W T D I

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://282213]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (19)
As of 2014-11-26 16:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls