Java Number Sign signum(final double x)

Here you can find the source of signum(final double x)

Description

Returns the signum function of the specified double value.

License

Open Source License

Return

the signum function of the specified double value.

Declaration

private static int signum(final double x) 

Method Source Code

//package com.java2s;
/*// www  . j  a  v  a 2  s.  c o m
 * KIELER - Kiel Integrated Environment for Layout Eclipse RichClient
 *
 * http://www.informatik.uni-kiel.de/rtsys/kieler/
 * 
 * Copyright 2008 by
 * + Christian-Albrechts-University of Kiel
 *   + Department of Computer Science
 *     + Real-Time and Embedded Systems Group
 * 
 * This code is provided under the terms of the Eclipse Public License (EPL).
 * See the file epl-v10.html for the license text.
 */

public class Main {
    /**
     * Returns the signum function of the specified <tt>double</tt> value. The
     * return value is -1 if the specified value is negative; 0 if the specified
     * value is zero; and 1 if the specified value is positive.
     * 
     * @return the signum function of the specified <tt>double</tt> value.
     */
    private static int signum(final double x) {
        if (x < 0) {
            return -1;
        }
        if (x > 0) {
            return 1;
        }
        return 0;
    }
}

Related

  1. signum(byte[] value)
  2. signum(Double d)
  3. signum(double value)
  4. signum(double z)
  5. signum(final int a)
  6. signum(final int i)
  7. signum(final int n)
  8. signum(final int value)