PDA

View Full Version : Programming problem



neo_philiac
07-11-2006, 04:26 PM
I hate myself asking this but I seem to have forgotten a simple programming technique...How do is check for set of logic ? i.e.

if (a=10 & b= 23){
.........}

A & B is a set that goes togeather. What I want to do is also check for c & d set. the logic is :

if a & b is true or if c & d is true then do something. How would i Do this? use case ? or if ((a=10 & b= 23) ||(c=15 & d= 3)) {} ...please help...

Twey
07-11-2006, 04:43 PM
if((a && b) || (c && d)) {
// ... do something ...
}& is a bitwise AND operator in most C-based languages; don't confuse it with &&, the boolean AND operator.
5 && 8 // Returns true in languages that convert from int to bool; anything other than 0 is considered true
5 & 8 // Returns 0, which equates as false in languages that convert from int to bool

This should be in the "Other" forum.