Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C Programming
Can anyone help me with this "if" condition please?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Stephen Sprunk, post: 3783506"] [i] To understand this, you must remember that, in C, things that look boolean are actually ints in disguise. In particular, the result of a comparison operator (e.g. <= or ==) is an int: 0 for false and 1 for true. You can do anything with these ints that you can any other int, like feed them into another comparison operator, add and subtract them, etc. This particular test checks that the primary conditions have the same result; the overall condition is true (1) if they are, false (0) if they're not. It might be easier to understand with an example of how the code might end up being evaluated: if ( (SomeFunc(Item[i], Col) <= Limit) == (V == 1) ) if ( (SomeFunc(1,2) <= 2.0) == (2 == 1) ) if ( (1.0 <= 2.0) == (0) ) if ( 1 == 0 ) if ( 0 ) S[/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Can anyone help me with this "if" condition please?
Top