and becomes or and or becomes and

S

Stef Mientki

hello,

must of us will not use single bits these days,
but at first sight, this looks funny :
6

cheers,
Stef
 
T

Thomas 'PointedEars' Lahn

Stef said:
must of us will not use single bits these days,
but at first sight, this looks funny :

6

Change the order of the operands and see what happens.
 
C

Chris Angelico

That IS funny.  Interesting how a careful choice of arugments will foolus.
One of my favorite math jokes is like that.  A teacher asked a student to
reduce the following fraction:
 16
 ----
 64

He says "all I have to do is cancel out the sixes, so the answer is 1/4".

I like. :)

But in the OP, the difference between "and" and "&", or "or" and "|",
is subtle yet absolute. They are completely different operators. The
bitwise operators function like the arithmetic operators - evaluate
both operands, then do something that combines them into one value.
The logical operators, though, are more like the if statement:

q = a and b

is similar to:

if a:
q = a
else:
q = b

(Pedants, please note that I said "similar" not "equivalent".) They
happen to do similar things, but they're completely different in
operation. I do like the humour value from the careful selection of
operands though!

Chris Angelico
 
S

Steven D'Aprano

That IS funny. Interesting how a careful choice of arugments will fool
us. One of my favorite math jokes is like that. A teacher asked a
student to reduce the following fraction:
16
----
64

He says "all I have to do is cancel out the sixes, so the answer is
1/4".

One of my favourite variations on this is by Abbott and Costello, where
Costello proves that 13*7 = 28 in three different ways.

 
C

Chris Angelico

And of course, a programmer cannot tell the difference between
Halloween and Christmas day.

Well known, of course. But a lot of modern programmers don't speak
octal, they only use another power-of-two base; it's as though
someone's cast a hex on them.

Chris Angelico
 
N

Nobody

That IS funny. Interesting how a careful choice of arugments will fool us.
One of my favorite math jokes is like that. A teacher asked a student to
reduce the following fraction:
16

Not Python, but:

#define SIX 1 + 5
#define NINE 8 + 1
...
printf("six times nine is: %d\n", SIX * NINE);
 
C

Chris Angelico

Not Python, but:

       #define SIX  1 + 5
       #define NINE 8 + 1
       ...
       printf("six times nine is: %d\n", SIX * NINE);

*AWESOME*!! That is brilliant!

DNA FTW.

ChrisA
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top