... You don't. They're undefined. See http://c-faq.com/expr/evalorder2.html In both cases, you can never know which out of the denominator or numerator is...
... No it doesn't. It's permissible for the compiler to _also_ interpret it as: c = 6/6 ... ... so that's wrong. Neither method is wrong, and because both are...
... "It is also possible the core of the earth is made of cheese. We just won't know until we get there." It is also possible that your hard drive will be...
... Given int a = 5; and int b = a / ++a; You don't know (and should never assume) whether the compiler will look at: o the 'a' first (and the '++a' second)...
A way to help determine how you want the following scenario to play out is to surround the piece of code you want to be sure is enacted on first with ( ). For...
... No it won't. Adding parenthesis does absolutely nothing in this situation. It's still invalid code, because either the numerator or denominator can be...
Which compiler are you using? Every compiler I know reads within ( ) first, and then from right to the left. The only time the code I present would have a...
... This is the special case where the same variable is accessed (both read and write, in this case) multiple times between sequence points. That's undefined...
Oh, so you're saying that it should be done more like.... int a; a = 6 / (++a); ... From: Brett McCoy <idragosani@...> Subject: Re: [c-prog] I am not...
... This applies to any compiler that attempts to adhere to The Standard(s.) ... No they don't. What the compilers do is first work out the value of each bit...
... I believe Paul's point is that incrementing a like that will be done before the numerator is taken into account, which will give you 1 every time. int a =...
Christopher Coale
chris95219@...
Jul 17, 2009 4:17 am
... Only if a and b were floats ;) (As I mentioned before, this is integer arithmetic) -- PJH http://shabbleland.myminicity.com/com ...
In your original code, what's 'a' initialized to? It looks like 'a' is not initialized, so '++a' is incrementing an uninitialized variable as it seems to me....
No: the issue is when you assign to a. You can always do something like int b=a/3+(a*4)-a; but when you use ++a your assigning/changing. ... From: Michael...
Tyler Littlefield
tyler@...
Jul 16, 2009 7:53 pm
OK, never-mind my last posting. I didn't see the part about init'ing a to 5. So I tried your operation: #include <iostream> #include <cstdlib> using...
Just so you know... Everything to the right of the assignment operator '=' happens first. So, even if you wrote your code as '++a' or as 'a++', 'a' would still...
... There is no guarantee in C or C++ of that being the case. Unlike some other languages, = is just another operator. In C and C++, side effects are only...
... Mom told me about putting a fork in the toaster, but when I tried it... ... The compiler is just one part of the implementation. Optimisors often work at a...