Java Abs abs(final double value)

Here you can find the source of abs(final double value)

Description

Return absolute value.

License

Creative Commons License

Parameter

Parameter Description
value Value to absolute.

Return

Absoluted value.

Declaration

public static double abs(final double value) 

Method Source Code

//package com.java2s;
/**//from w  w  w.j  av  a 2 s  .  c  om
 * Static helper class to centralize various useful methods
 * that do not fit in any other util.
 * Copyright (c) 2015 Vinland Solutions
 * Creative Commons Attribution-NonCommercial <http://creativecommons.org/licenses/by-nc/3.0/deed.en_US>
 * @author JayJeckel <http://minecraft.jeckelland.site88.net/>
 */

public class Main {
    /**
     * Return absolute value.
     * @param value Value to absolute.
     * @return Absoluted value.
     */
    public static short abs(final short value) {
        return (value < 0 ? (short) -value : value);
    }

    /**
     * Return absolute value.
     * @param value Value to absolute.
     * @return Absoluted value.
     */
    public static int abs(final int value) {
        return (value < 0 ? -value : value);
    }

    /**
     * Return absolute value.
     * @param value Value to absolute.
     * @return Absoluted value.
     */
    public static long abs(final long value) {
        return (value < 0 ? -value : value);
    }

    /**
     * Return absolute value.
     * @param value Value to absolute.
     * @return Absoluted value.
     */
    public static float abs(final float value) {
        return (value < 0 ? -value : value);
    }

    /**
     * Return absolute value.
     * @param value Value to absolute.
     * @return Absoluted value.
     */
    public static double abs(final double value) {
        return (value < 0 ? -value : value);
    }
}

Related

  1. abs(double[] in)
  2. abs(double[] v)
  3. abs(double[][] A)
  4. abs(final byte x)
  5. abs(final double d)
  6. abs(final double x)
  7. abs(final int pNumber)
  8. abs(float f)
  9. abs(float value)