Java Number Sign signum(int v)

Here you can find the source of signum(int v)

Description

Returns the sign of a number: either -1, 0 or 1.

License

Open Source License

Declaration

public static int signum(int v) 

Method Source Code

//package com.java2s;
/*/* w  w w  .j  ava2s  . co  m*/
 * BioAssay Ontology Annotator Tools
 * 
 * (c) 2014-2016 Collaborative Drug Discovery Inc.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License 2.0
 * as published by the Free Software Foundation:
 * 
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 */

public class Main {
    /**
     * Returns the sign of a number: either -1, 0 or 1.
     */
    public static int signum(int v) {
        return v < 0 ? -1 : v > 0 ? 1 : 0;
    }

    /**
     * Returns the sign of a number: either -1, 0 or 1.
     */
    public static int signum(float v) {
        return v < 0 ? -1 : v > 0 ? 1 : 0;
    }

    /**
     * Returns the sign of a number: either -1, 0 or 1.
     */
    public static int signum(double v) {
        return v < 0 ? -1 : v > 0 ? 1 : 0;
    }
}

Related

  1. signum(final int n)
  2. signum(final int value)
  3. signum(float f)
  4. signum(float val)
  5. signum(int a)
  6. signum(long diff)
  7. signum(long l)
  8. signum(long number)
  9. signumEps(double val, double eps)