# Thread: <?= operator

1. ## <?= operator

Hi,
I have such code:
Code:
```for(int i=0;i++<limit; maxx <?= rt + tt)
{
...
}```
Can anyone explan what does this operator <?= do?
Thanks.

2. I don't think that's valid code. (Although it might be a digraph I don't know about.)

3. Well, I compiled it and it works fine.
Regards.

4. Ah! I know! <? is !. So <?= is the same as !=.

5. Thanks, is there any reason of using something like that ?

6. Originally Posted by apacz
Thanks, is there any reason of using something like that ?
Obfuscation perhaps..

There are contests to have the most obscure code, or simply to have the most obsure code (encrypted so it couldnt be understood )

7. Sweetie, '?' is the ternary operator, otherwise known as the conditional operator. It's called 'ternary' because it works with THREE operands...unlike something like '+' which works with two: (x+y).

Code:
```     int x=2, y=5, z=0; //Our three operands
z = (x > y) ? (x:y); //Assign z to the bigger one.```
This is the alternative to if/else statements: it reads: "If x > y, assign x's value to z. Else, assign z the value of y."

8. How does that work in the situation its being used here?

Code:
`maxx <?= rt + tt`
if maxx is 0, assign it to rt + tt? I'm confused already.

9. How does that work in the situation its being used here?

Code:
`maxx <?= rt + tt`
if maxx is 0, assign it to rt + tt? I'm confused already.

It cant be != like dwks said though, because its in the third section of the for statement..

10. <? is described as a trigraph. The purpose of trigraphs is to allow programmers to work with keyboards that do not support certain characters. Most common scenario is on keyboards designed for non-english speakers (eg Scandinavian languages) <? expands to an exclamation mark (!)

11. In this case it is indeed a digraph take means !

However it is not defined in the standard so use at your own risk.

12. >>However it is not defined in the standard so use at your own risk.

ok mom.

why is everyone so anal about standard code?
his own risk? a bit harsh a word considering all he wanted to know what what it meant.

Ya, i'm just a bit annoyed right now at everyone harrassing me about "why are you writing it that way."

13. Originally Posted by jrahhali
why is everyone so anal about standard code?
his own risk? a bit harsh a word considering all he wanted to know what what it meant.
Because not everyone in the world uses the same compiler or OS. By following the standard you help ensure that the program will run as intended regardless of the machine. Of course there are times when the standard has to go out the window to solve a problem. However the likelyhood of someone posting a question on this board in which that would be the case is pretty slim.

Now how about you tell me why you think you shouldn't follow the standard?

Edit: Also about getting annoyed about people asking why you did something a certain way: Get used to it. You should be confident enough to explain exactly why you did something a particular way. And that doesn't go just for programming but for all areas of your work. When I worked as a switchboard tech I was asked quite regularly how I came to a conclusion and why I went with a particular path for solving the problem.

14. >>Now how about you tell me why you think you shouldn't follow the standard?

But for his purposes, he wanted to know what it meant.

edit: nvm..nvm. bye.

15. When people say "use at your own" it doesnt just mean the OP, its anyone reading this to know that information. Also he is using that code apparently, and if using <? is unsafe I'm sure you would want to at least know.

Anyway, question... what exactly the purpose of the third statement in this for loop?

Code:
```for(int i = 0; i++ < limit; maxx != rt + tt)
{
...
}```
Its not even in the condition statement.

Popular pages Recent additions