Tips on Using Boolean Logic

Tips on Using Boolean Logic

Programmer’s of all skill levels often make errors when using Booleanlogic. This statement might not evaluate the way you think it should:

 IF (SomeNumber AND 16) OR _ (SomeOtherNumber  0) THEN... 

The (SomeNumber AND 16) will never return a True (-1). It willreturn False (0) or False (some value). Always phrase your evaluationsin a TRUE, FALSE, or ZERO ( ZERO in this case means “hasvalue” as opposed to NOT FALSE which means TRUE (-1)). Not only willyour logical intention be better understood, you’ll be less likely to experiencea logic fault that would be a bear to track down.


Share the Post: