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="Lew Pitcher, post: 3783476"] [i] Gaak! What some programmers won't do to avoid coding boolean operators. OTOH, this condition /is/ shorter than the corresponding code w booleans. Take this piece by piece This if condition is coded as (something) == (something_else) The (something) is (SomeFunc(Item[i], Col) <= Limit) which compares the return value from SomeFunc() to the value of Limit. If SomeFunc() returned a value that is less than or equal to Limit, the result of this bracketed expression is 1 (the "true" value in C), otherwise, the result is 0. The (something_else) is (V == 1) which compares the value of V to 1. If V is equal to 1, then the result of this bracketed expression is 1, otherwise, the result is 0. The ((something) == (something_else)) compares the value of the (something) expression to the value of the (something_else) expression. If these are equal, then the result is 1 ("true"), otherwise the result is 0. The if statement evaluates the entire condition, and if the condition is true, then the "true" branch of the statement is executed. Otherwise, the "false" branch of the if statement is executed. So, to get to the "true" branch of the if() statement, either a) SomeFunc(Item[i],Col) must be less than or equal to Limit /and/ V must equal 1 or b) SomeFunc(Item[1],Col) must *not* be less than or equal to Limit /and/ V must *not* equal 1 -- Lew Pitcher Master Codewright & JOAT-in-training | Registered Linux User #112576 [URL]http://pitcher.digitalfreehold.ca/[/URL] | GPG public key available by request ---------- Slackware - Because I know what I'm doing. ------[/i][/i][/i] [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C Programming
Can anyone help me with this "if" condition please?
Top