PC Review


Reply
Thread Tools Rate Thread

Different uses of AND function

 
 
Mathieu936
Guest
Posts: n/a
 
      25th Aug 2010
Hi!

I have a code from an unknow author which I try to understand, but I
can't! Can you help me guys?

The code is:

Function bitcheck(ival As Integer, ibit As Integer)
bitcheck = 0
If (ival And 2 ^ ibit) > 0 Then bitcheck = 1
End Function

But when I change the If statement for this:
If ival > 0 and 2 ^ ibit > 0 then bitcheck = 1

the function does not give the same answer. Why??

Thanks!
 
Reply With Quote
 
 
 
 
Scossa
Guest
Posts: n/a
 
      25th Aug 2010
On 25 Ago, 22:13, Mathieu936 <mathieu...@gmail.com> wrote:
> Hi!
>
> I have a code from an unknow author which I try to understand, but I
> can't! Can you help me guys?
>
> The code is:
>
> Function bitcheck(ival As Integer, ibit As Integer)
> * *bitcheck = 0
> * *If (ival And 2 ^ ibit) > 0 Then bitcheck = 1
> End Function


in this code AND is used as binary operator:

debug.print 3 AND 2 ' -> 11 and 10 -> 10 = 2
debug.print 2 AND 2 ' -> 10 and 10 -> 10 = 2
debug.print 1 AND 2 ' -> 01 and 10 -> 00 = 0
debug.print 3 AND 1 ' -> 11 and 01 -> 01 = 1


> * *If ival > 0 and 2 ^ ibit > 0 then bitcheck = 1


in your code AND is used as logic operator:
debug.print true and true -> true
debig.print false and true -> false

Bye!
Scossa
 
Reply With Quote
 
Mathieu936
Guest
Posts: n/a
 
      26th Aug 2010
Hey Thanks Scossa!

I would never found it by myself!

Mathieu

 
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
User Function Question: Collect Condition in Dialog Box - But How toInsert into Function Equation? SteveM Microsoft Excel Programming 1 3rd Jan 2008 03:45 PM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft Dot NET Framework 1 22nd Nov 2007 11:36 AM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft ADO .NET 3 22nd Nov 2007 09:17 AM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft VB .NET 0 20th Nov 2007 04:24 AM
I have a CLR function thet returns IEnumberable (a table) and it has a FillRow function. I am returning 10,000 integers from this function. Is there any way that I can preallocate the resulting table or give SQL server hint as to how many rows my fun DR Microsoft Dot NET 0 20th Nov 2007 04:24 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:06 PM.