🔒 Locked
(!( && !
Advertisement
Original Post
It won''t compile? Then why do error checking that way?
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Never mind. I just saw Sneftel said that it''s checking if it''s FALSE.
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
now, "if(!blah)" expands to "if(!foo && myfunc(4))", but "if(!(blah))" expands to "if(!(foo && myfunc(4)))"
Again, wouldn''t that be the same thing?
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Again, wouldn''t that be the same thing?
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
quote:
Original post by Tazel
Again, wouldn''t that be the same thing?
no.
"if(!foo && myfunc(4))" means if foo is false and myfunc(4) is true then execute the following logic
"if(!(foo && myfunc(4)))" means if BOTH foo and myfunc(4) are false then execute the following logic.
those are quite different
-me
No. You have to use order of operations.
"if(!blah)" expands to "if(!foo && myfunc(4))"
would resolve to "if foo is not true, and myfunc(4) is true"
"if(!(blah))" expands to "if(!(foo && myfunc(4)))"
would resolve to "the opposite of the result of checking if foo and myfunc(4) are both true".
-fel
"if(!blah)" expands to "if(!foo && myfunc(4))"
would resolve to "if foo is not true, and myfunc(4) is true"
"if(!(blah))" expands to "if(!(foo && myfunc(4)))"
would resolve to "the opposite of the result of checking if foo and myfunc(4) are both true".
-fel
I see. So that happens when there are more than one things being evaluated.
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
You understand Order of Operations, right Tazel? You know that
2 + 1 * 6 is different than
(2 + 1) * 6 ?
We just added some more operations into the order of operations, that you might not be used to. So, when in doubt, use more parenthesis. Or look up "operator precedence" and see what tier it''s on.
-fel
2 + 1 * 6 is different than
(2 + 1) * 6 ?
We just added some more operations into the order of operations, that you might not be used to. So, when in doubt, use more parenthesis. Or look up "operator precedence" and see what tier it''s on.
-fel
This is why, if you feel the need to use macros, you must make liberal use of parentheses in the macro if it starts to gain much any kind of complexity, unless it''s the intended behaviour.
Fel: Yes. The parentheses and any grouping symbol''s contents are evaluated first.
Then powers.
Then multiplication and division from left to right.
Then add. and sub. from left to right.
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Then powers.
Then multiplication and division from left to right.
Then add. and sub. from left to right.
tcache
Contact Me
-----------
AH! MY BRAIN IS GOING TO SELF-DETONATE! -- Yours Truly (Jan, 2003)
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement