Skip to content

Find the sign

4 messages · Alaios, Henrique Dallazuanna, Rainer Schuermann +1 more

#
Hello :)
I wanted to right an expression to check when x and y have the same sign
and I wrote the following:

 if ((x<0 && y<0) || (x>0 && y>0)) 

which looks pretty ugly to me.

Can you please suggest me a better way for that?

Regards
Alex
#
On Monday, January 24, 2011 07:18:03 pm Alaios wrote:
if( sign( x ) == sign( y ) )
#
if (x*y>0) {...}

On Mon, Jan 24, 2011 at 1:27 PM, Rainer Schuermann
<Rainer.Schuermann at gmx.net> wrote: