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="dj3vande, post: 3783482"] [i] It's comparing the results of two comparisons (return value of SomeFunc for "not bigger than Limit", and V for "is it 1"). The '==' between them checks whether the two comparisons give the same result. So if they both pass (SomeFunc returns a small enough value and V is 1), or if they both fail (SomeFunc returns a larger value and V is not 1), the if branch will be taken. If one of the checks passes and the other fails, the if branch won't be taken. If it were code I was maintaining, I would probably add a short comment describing what's going on and leave the code as it is. You could rewrite it as -------- check1 = (SomeFunc(Item[i],Col) <= Limit); check2 = (V == 1); if((check1 && check2) || (!check1 && !check2)) { /*...*/ } -------- which might make it more obvious what it's doing, but the extra checks and the temporaries would impair clarity as much as taking out the direct comparison of the results of other comparisons would improve it. dave[/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Can anyone help me with this "if" condition please?
Top