# <?= operator

Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last
• 09-24-2005
apacz
<?= 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.
• 09-24-2005
dwks
I don't think that's valid code. (Although it might be a digraph I don't know about.)
• 09-24-2005
apacz
Well, I compiled it and it works fine.
Regards.
• 09-24-2005
dwks
Ah! I know! <? is !. So <?= is the same as !=.
• 09-24-2005
apacz
Thanks, is there any reason of using something like that ?
• 09-24-2005
Dae
Quote:

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 :rolleyes: )
• 09-24-2005
Krak
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."
• 09-24-2005
Dae
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.
• 09-24-2005
Dae
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..
• 09-24-2005
grumpy
<? 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 (!)
• 09-24-2005
Thantos
In this case it is indeed a digraph take means !

However it is not defined in the standard so use at your own risk.
• 09-24-2005
jrahhali
>>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."
• 09-24-2005
Thantos
Quote:

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.
• 09-24-2005
jrahhali
>>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.
• 09-24-2005
Dae
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.
Show 80 post(s) from this thread on one page
Page 1 of 2 12 Last