What Java method takes an int
and returns +1 or -1? The criteria for this is whether or not the int
is positive or negative. I looked through the docum
Math.signum(double i)
Returns the signum function of the argument; zero if the argument is zero, 1.0 if the argument is greater than zero, -1.0 if the argument is less than zero. Special Cases:
NaN
, then the result is NaN
.Parameters:
Returns: The signum function of the argument
Since: 1.5