PC Review


Reply
Thread Tools Rate Thread

'case' vs. 'case is'

 
 
darrel
Guest
Posts: n/a
 
      14th Aug 2008
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

 
Reply With Quote
 
 
 
 
Rory Becker
Guest
Posts: n/a
 
      14th Aug 2008
Hello darrel,

> 2 or 3


is a bitwise comparison and results in 3. Hence 2 does not trigger this case

--
Rory


 
Reply With Quote
 
darrel
Guest
Posts: n/a
 
      14th Aug 2008

> is a bitwise comparison and results in 3. Hence 2 does not trigger this
> case


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

-Darrel

 
Reply With Quote
 
Rory Becker
Guest
Posts: n/a
 
      14th Aug 2008
Hello darrel,

>> is a bitwise comparison and results in 3. Hence 2 does not trigger
>> this case
>>

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

--
Ror


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Minor puzzle: some UDF calls respect mixed case, others insist onlower case Dave Peterson Microsoft Excel Programming 0 1st May 2010 12:32 AM
Re: Minor puzzle: some UDF calls respect mixed case, others insist on lower case JLGWhiz Microsoft Excel Programming 2 30th Apr 2010 09:09 PM
Comparing text fields to find upper case lower case mismatches RAN Microsoft Access Queries 3 4th Dec 2008 04:34 PM
Can't find short cut for changing case ... upper case .... lower case JERRY Microsoft Word New Users 7 23rd Aug 2007 05:29 PM
Lower case, upper case mish mash in Headings-based bookmarks =?Utf-8?B?UnV0YWJhZ2E=?= Microsoft Word Document Management 3 10th May 2007 10:17 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:32 AM.