Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 268

 
borilunad:

I couldn't find this case in the Dock. How much more unknown-unfamiliarity awaits us!

Read the expression from left to right by default.
 
VladislavVG:

Why is there an error? Both are correct from the compiler's point of view, but they mean different things and that's up to the programmer ;).

Don't be misled. The result of a Boolean operation will be 0 or 1 (I'm guessing), so the expressions are non-equivalent regardless of how the operators are evaluated, because the second comparison will be to a Boolean result.
 
TheXpert:
Don't be misled. The result of a Boolean operation will be 0 or 1 (I assume), so the expressions are non-equivalent regardless of the order in which the operators are evaluated, because the second comparison will be with a Boolean result.

Are we talking about common sense yet?
 
TheXpert:
Don't be misled. The result of a Boolean operation will be 0 or 1 (I assume), so the expressions are non-equivalent regardless of the order in which the operators are evaluated, because the second comparison will be with a Boolean result.

Quite right and this 0/1 will be compared to N. And where did I mislead ? And what equivalence of expressions are you talking about ?
 
VladislavVG:

Exactly right and this 0/1 will be compared to N. And where did I mislead ? And what equivalence of expressions are you talking about?

That wasn't addressed to you, ichyko.
 
tara:

That wasn't addressed to you, ichyko.


Well in this post TheXpert is quoting from my post. Therefore, one can understand that it is a response to my statement.

I wasn't talking about equivalence of expressions. I was talking about correct syntax from the compiler's point of view in both expressions - it even says that these expressions mean different things.

I think I may have problems with the Russian language: after all, I live in Ukraine and the latest trends in the Russian language may well have missed. That's why I'm trying to clarify: what kind of my words were used to make a conclusion about the equivalence of expressions. Maybe I did mislead - then it is necessary to clarify my statements so that there is no possibility of ambiguous interpretations.
 
Zhunko:
By default, read the expression from left to right.
I got this expression by accident after editing the code, but now I just left it if(n < N), which is easier and doesn't bother me too much. And when I'll need something like this, I'll know I can do it that way too! Thank you, you've explained! And I still can't seem to get to C, although I have a huge volume of more than a thousand pages of C++ for a long time! Still can not, EVERYTHING eats all the time!
 
VladislavVG:
And where did I mislead?
OK, nowhere. But it's better to talk about such things explicitly. Otherwise, some people won't understand, like me.
 
So, what about the newbies, gentlemen?
 
borilunad:
I obtained this expression by accident after editing the code and now I just use if(n < N) since it is easier and does not bother me too much. And when I'll need something like that, I'll know that I can do it that way too! Thank you, you've explained! And I still can't seem to get to C, although I have a huge volume of more than a thousand pages of C++ for a long time! Still can not, EVERYTHING eats all the time!


I do not think that such a construction in MKL will stand for what you want. So a tip from personal experience: use brackets to explicitly specify the order of calculations, do not rely on the compiler. In your case it would be better (in the sense of clearer) to write it like this:

if( (n>=0) &&(n<N) ) then the risk of logic error is minimal. IMHO, of course.

Reason: