1
$\begingroup$

Is there an equation, that will return either 1 if a variable is positive, or 0 if the variable is negative.

For example, to see if an integer is odd or even you can use:

$$r=\frac{(-1)^n+1}{2}$$

where $r$ will be $1$ if $n$ is even, and $r$ will be $0$ if $n$ is odd.

So is there a similar equation, to see if $n$ is positive or negative?

(sorry I have no idea what to tag this)

3 Answers 3