Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Logical and Bitwise AND (and) ORs

Author
Message
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 4th Jul 2003 19:08
Hello.

In a nutshell, and without using big words (because they confuse me), please can someone explain to muggins here what exactly is the difference between a logical AND and a bitwise AND. Likewise, OR.

I am assuming that a logical AND/OR will work on the whole variable but that a bitwise AND/OR will only work on the first bit. However, this is probably wrong, as I usually am when I guess stuff.

Cheers

Phil
Coming up... a hell of a 3D Space Trading Game!
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 4th Jul 2003 19:09
PS: And if anyone happens to have any lunch hampers, they'd be much appreciated.

Coming up... a hell of a 3D Space Trading Game!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 4th Jul 2003 20:37
Logical operators use the whole value, counting 0 as false, and any other number as true.

Bitwise operators use each individual bit within the value.

Eg (all numbers are binary)

10101010 'logical and' 01011011 = 1
10101010 'bitwise and' 01011011 = 00001010
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 5th Jul 2003 07:55 Edited at: 5th Jul 2003 07:58
Aha. Thanks for that IanM. Yet again, you have saved my bacon.

I am guessing that in DBP the "AND" and "OR" commands actually perform as both logical and bitwise comparators depending on their context. So if I write:



Thats a logical comparator.

But if I write:



Thats a bitwise comparator.

Phil

Coming up... a hell of a 3D Space Trading Game!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jul 2003 14:52


Actually, DBPro doesn't seem to have logical equivalents of these operators - everything is bitwise, so you have to work harder if you want logical operations.



Also, you can substitute '&&' for 'and', '||' for 'or' - just in case you see code with them in.
Dave J
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Feb 2003
Location: Secret Military Pub, Down Under
Posted: 5th Jul 2003 15:29
Hmm, I thought DBP only used Logical and not Bitwise lol.

"Computers are useless they can only give you answers."
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 5th Jul 2003 17:28
I understand. My programme only compares variables with two states: 1 (true) and 0 (false). Therefore, "and" and "or" should be ok I think.

Phil

Coming up... a hell of a 3D Space Trading Game!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Jul 2003 19:12
Yep
Philip
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: United Kingdom
Posted: 5th Jul 2003 19:55
Thanks!

(Gives IanM a spare lunch hamper)

Coming up... a hell of a 3D Space Trading Game!

Login to post a reply

Server time is: 2024-09-20 13:35:35
Your offset time is: 2024-09-20 13:35:35