Unary operator and binary operator

• 08-27-2013, 11:51 AM
suhaas.mohandos@gmail.com
Unary operator and binary operator
Acc. to the definition a unary operator(+) operates on one operand.

1. int a=1+1;
2. int b=+a;

Now in the line 1 the + operator is used for two operands, while the line 2 operates on one operand. So how can + be called a unary operator or even binary operator, for that matter?
• 08-27-2013, 12:20 PM
JosAH
Re: Unary operator and binary operator
Those are two different operators that look the same (+); distinguishing between them is a little linguistic problem to be solved by the compiler (blame mathematics for it).

kind regards,

Jos
• 08-27-2013, 12:52 PM
allaudin
Re: Unary operator and binary operator
In programming, "+" is defined as the unary plus operator that makes an expression positive (however, numbers are positive without this), e.g int number = +1; however "+=" is assingment operator.
• 08-27-2013, 01:27 PM
JosAH
Re: Unary operator and binary operator
Quote:

Originally Posted by allaudin
In programming, "+" is defined as the unary plus operator that makes an expression positive (however, numbers are positive without this), e.g int number = +1; however "+=" is assingment operator.

That was not what the OP was asking for and besides, the unary + operator doesn't make the value of the expression positive, e.g. int a= +-3; doesn't make a == 3; stop spewing your incorrect advice in these forums.

Jos
• 08-27-2013, 02:27 PM
allaudin
Re: Unary operator and binary operator
Quote:

That was not what the OP was asking for and besides, the unary + operator doesn't make the value of the expression positive, e.g. int a= +-3; doesn't make a == 3; stop spewing your incorrect advice in these forums.

Jos
that was not my definiton ... Unary Operators and another Unary Operator - Definition for the Term: Unary Operator I already know you will say its wrong but not this time :P :D:
• 08-27-2013, 02:55 PM
JosAH
Re: Unary operator and binary operator
Quote:

Originally Posted by allaudin
that was not my definiton ... Unary Operators and another Unary Operator - Definition for the Term: Unary Operator I already know you will say its wrong but not this time :P :D:

That Rose India site sucks big times; it should be taken off line.

Jos
• 08-27-2013, 03:02 PM
PhHein
Re: Unary operator and binary operator
Quote:

Originally Posted by JosAH
That Rose India site sucks big times; it should be taken off line.

Jos

Full ack!
• 08-27-2013, 03:03 PM
gimbal2
Re: Unary operator and binary operator
Quote:

Originally Posted by PhHein
Full ack!

Ack ack.
• 08-27-2013, 04:14 PM
DarrylBurke
Re: Unary operator and binary operator
Quote:

Originally Posted by gimbal2
Quote:

Originally Posted by PhHein
Full ack!

Ack ack.

Ack.
• 08-27-2013, 04:29 PM
JosAH
Re: Unary operator and binary operator
Quote:

Originally Posted by allaudin
that was not my definiton ... Unary Operators and another Unary Operator - Definition for the Term: Unary Operator I already know you will say its wrong but not this time :P :D:

See? It's not just me who detests that site; and you buntly posted it here as if it were the truth; it's far from it; I'm telling you for the last time (not asking it): stop posting all your nonsense in these forums. You are just a 'sheer beginner' (your own terminology) and not in a position to help out other posters. You merely ruin the threads. You'd better study first before you open your mouth again.

Jos
• 08-27-2013, 04:39 PM
jim829
Re: Unary operator and binary operator
Interesting! Looks like I got lucky when I chose this site. I haven't checked out Rose India. And looks like I probably won't.

Regards,
Jim