# <?= operator

This is a discussion on <?= operator within the C++ Programming forums, part of the General Programming Boards category; I would imagine maxx would be used inside the loop....

1. I would imagine maxx would be used inside the loop.

2. Originally Posted by Thantos
I would imagine maxx would be used inside the loop.
Dae.IQ = Dae.IQ - 20;

I don't know what you mean. Of course its possible maxx was used inside the loop, but what does stating maxx != rt + tt every increment do? its not a condition, its a statement.. right?

Code:
```for(int i = 0; i++ < limit; )
{
maxx != rt + tt;
}```
Its not a condition, its just.. out there.. for what reason?

Sorry I cant see any reason for why its there, other than none.

3. You tell me where it states that the third part of the for loop has to have anything to do with the first two parts. Heck I remember some interesting for loops posted on this board by some very bored programmers.

4. Originally Posted by Thantos
You tell me where it states that the third part of the for loop has to have anything to do with the first two parts. Heck I remember some interesting for loops posted on this board by some very bored programmers.
I'm not saying the third part of the for loop has to have anything to do with the others. I am saying that the first part of the for loop only occurs once (creation), at the beginning, of the for loop, the second part is the condition that is checked if still 1 (true) at the end of each loop, and the third is something that you want to occur at the end of every loop. Now why would you want 'maxx != rt + tt' to occur at the end of every loop? its not attached to an if statement, so there would be no purpose to it.. right? wrong? thats what I'm wondering.

Code:
```for(int i = 0; i++ < limit; maxx != rt + tt)
{
...
}

is equal to:

for(int i = 0; i++ < limit; )
{
maxx != rt + tt;
}```
Code:
```for(int i = 0; i++ < limit; maxx != rt + tt)
{
...
}

is equal to:

for(int i = 0; ; maxx != rt + tt)
{
if(!(i++ < limit))
break;
}```
Since its a condition it should be in the second part of the for loop, or be attached to an if statement:

Code:
```for(int i = 0; i++ < limit; if(maxx != rt + tt) break)
{
...
}

is equal to:

for(int i = 0; i++ < limit; )
{
if(maxx != rt + tt)
break;
}```

5. Who knows why they did it, its probably just a mistake they made, but really who cares?

6. It's actually a GCCism. a <?= b means the same as a < b ? a : b. In english, assign the minimum of a and b to a. You see stuff like that a lot in Topcoder from people trying to squeeze every second of time in their solutions.

7. Originally Posted by Thantos
Who knows why they did it, its probably just a mistake they made, but really who cares?
I only wondered because half the people said it was short for !, and the other half said it was y > x ? x : y. The way its placed it doesnt make sense to be a trigraph. I guess with SilentStrike's reply thats right, that makes sense now.

8. > from people trying to squeeze every second of time in their solutions.
Gotta be a real moron to believe that the number of characters your program occupies has anything to do with the performance of the code.

Do they really believe that since a <?= b takes fewer characters than a < b ? a : b, that the compiler will generate fewer compare instructions or branch instructions?

9. Originally Posted by Salem
> from people trying to squeeze every second of time in their solutions.
Gotta be a real moron to believe that the number of characters your program occupies has anything to do with the performance of the code.

Do they really believe that since a <?= b takes fewer characters than a < b ? a : b, that the compiler will generate fewer compare instructions or branch instructions?
Yes, you are correct; it is true that idiots exist. Either the programmer's an idiot, or the compiler creator is an idiot.

If there is some programmer or compiler creator here that I've just insulted, this thread should take an interesting turn :-)

Of course, these artifacts from nonstandardized days shouldn't be forcibly removed from compilers, so we're being a bit unfair.

10. Gotta be a real moron to believe that the number of characters your program occupies has anything to do with the performance of the code.
Actually, I'd say these people are MUCH smarter than me, and probably a bit smarter than you. They are squeezing seconds off of coding time, not running time.

Take a look at this, for example [registration required].

http://www.topcoder.com/stat?c=probl...696&cr=8355516

The code is cryptic, but I don't think you nor I would solve the problem in 7 minutes.

I actually have found that using <?= and >?= makes my code more buggy, since I somtimes omit characters and then do assignments or other similiar dumb stuff.

11. Originally Posted by Dae
Sorry I cant see any reason for why its there, other than none.
How do you know maxx, rt, or tt aren't objects with the != and + operators overloaded for some reason? The maxx != rt + tt statement might actually do something useful, although I really can't find a good reason why he would do it with those operators (especially !=) since it isn't intuitive.

12. If I recall correctly, a for statement that looks like this:

Code:
```for (initializing statement; condition; expression)
statement```
is basically the same as:

Code:
```initializing statment
while (condition)
{
statement;
expression;}```
So really, the expression can be just about anything. Though usually used to increment the loop, here it could be used just to update the variable. Maybe rt and tt change during the loop, and the OP wants to make sure that maxx = rt + tt at the end of each cycle through the loop. If you wanted to produce all fibonacci numbers under n, you could use it:
Code:
```#include <cstdlib>
#include <iostream>

using namespace std;

int main()
{
int oldFibo = 0;
int olderFibo = 0;
int n = 100;

for (int fibo = 1; fibo < n; fibo = oldFibo + olderFibo)
{
olderFibo = oldFibo;
oldFibo = fibo;
cout << fibo << endl;
}

system("pause");
return 0;
}```

13. > They are squeezing seconds off of coding time, not running time.
Absolutely pathetic reason if you ask me.

The biggest cost in software is understanding what the other person wrote (or even your own code) months after the event when it doesn't work anymore or needs to be enhanced.
Ever looked at any of your old "smart" code and wondered what the hell you were thinking of at the time?

Every stupid little trick in the book which obfuscates the code in some way simply adds to the difficulty.

I suppose they still think the xor swap without a temp is a really neat idea.

14. Originally Posted by Speedy5
How do you know maxx, rt, or tt aren't objects with the != and + operators overloaded for some reason? The maxx != rt + tt statement might actually do something useful, although I really can't find a good reason why he would do it with those operators (especially !=) since it isn't intuitive.
That would be a very good point, lol, a little too late.. but very good point.

However, you cant overload <?=, and that is what was in the code, and someone said it stands for !=, which is the only reason I used != in that code you quoted.

15. Originally Posted by Decrypt
If I recall correctly, a for statement that looks like this:

Code:
```for (initializing statement; condition; expression)
statement```
is basically the same as:

Code:
```initializing statment
while (condition)
{
statement;
expression;}```
So really, the expression can be just about anything. Though usually used to increment the loop, here it could be used just to update the variable. Maybe rt and tt change during the loop, and the OP wants to make sure that maxx = rt + tt at the end of each cycle through the loop. If you wanted to produce all fibonacci numbers under n, you could use it:
[code]#include <cstdlib>
#include <iostream>
You're right, it can be anything - as I said. However the condition statement is automatically considered to operate like an if statement, while the expression part does not. Hence if the OP was trying to check if maxx != tt + rt, he would have to use an if statement around it in the expression - as I exampled. Without the if statement (as it is in the OP's code) it does not make sense to be the != operator, as we now know according to SilentStrike.

Page 2 of 2 First 12