'case' vs. 'case is'

D

darrel

Is there a difference? I'm looking through some code where they have this:

case is = 2 or 3

If the select is 2, that case is not triggered.

If I add this to the statement:

case = 2, 3

then it's caught.

So, I assume 'is' different, I'm just not sure in which way and when one
would actually want to use it.

-Darrel
 
R

Rory Becker

Hello darrel,
Off to google 'bitwise comparison'. Thanks for the lead! ;o)

should have said "bitwise operator" sorry

Basically you are combining the 2 values by oring them together
Consider their binary representations

00000011 = 3
00000010 = 2

To Or them together you say that the result will be 1 where either of the
values to be combined is 1

This results in a 1 in the right-most 2 positions which is equivalent to 3.

If you had used AND instead of OR then you would have had a 1 in a given
position if there was a 1 in the first AND the second values

resulting in a 1 in only the second from right position which would equate
to 2

Try to imagine brackets around the "2 OR 3" and evaluate this first.
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top