Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

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

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"
$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...


Comment on Re: Bit operations for beginners
Select or Download Code
Replies are listed 'Best First'.
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?

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2015-11-28 05:39 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (738 votes), past polls