Thread: Boolean Algebra
View Single Post
Join Date: Dec 2004
Posts: 445
Reputation: 1o0oBhP is an unknown quantity at this point 
Solved Threads: 6
1o0oBhP's Avatar
1o0oBhP 1o0oBhP is offline Offline
Posting Pro in Training

Re: Boolean Algebra

 
0
  #5
Dec 13th, 2004
Correction:

(statment) ? a : b

if the statement is true it takes a
if the statement is false it takes b

however because you cant use block statements like the if function it is only useful to save coding space if the only action taken is to give the variable a value. for example

if(x == 0)
{
MessageBox(NULL, "X = 0", "Message", MB_ICONINFORMATION | MB_OK);
SomeOtherFunction();
...
}
else
{
....
}

cannot be simplified but...

the abs function (always +) which is:

if(a > 0)
return a;
else
return -a;

can be defined as

#define abs(a) (a > 0) ? a : -a;
http://sales.carina-e.com

no www
no nonsense

coming soon to a pc near you! :cool:
Reply With Quote