Sunday, July 12, 2009

C if statement with address of operator?

I came across an if statement like so.





if( val_one %26amp; val_two )





Could someone explain what's been tested here?

C if statement with address of operator?
this statement evaluates val_one and val_two using bit-wise comparison. It compares each digit of the binary value of val_one with the corresponding digit of binary value of val_two. The resulting binary number is being tested to be greater than 0.





In short, if either one of val_one or val_two are 0 the code inside the if block will not execute.
Reply:The single ampersand sign (%26amp;) is the modulus operator. So, the test is looking for a remainder of val_one / val_two.





IGNORE ABOVE - Danprem below is correct. Getting my languages mixed up. 8=]
Reply:if both "val_one " and "val_two" are set, only then execute the IF command


No comments:

Post a Comment