Example usage for java.lang Math abs

List of usage examples for java.lang Math abs

Introduction

In this page you can find the example usage for java.lang Math abs.

Prototype

@HotSpotIntrinsicCandidate
public static double abs(double a) 

Source Link

Document

Returns the absolute value of a double value.

Usage

From source file:Main.java

public static boolean g(double a, double c) {
    return 1E-8 > Math.abs(a - c);
}

From source file:Main.java

public static boolean isEqualToZero(double value) {
    return Math.abs(value - 0.0) < 0.01 ? true : false;
}

From source file:Main.java

public static float getDistance(float x1, float x2) {
    return Math.abs(x1 - x2);
}

From source file:Main.java

public static boolean equal(double d1, double d2) {
    if (Math.abs(d1 - d2) < 0.1) {
        return true;
    }//from  www .  j  a  v  a 2s .  co m
    return false;
}

From source file:Main.java

public static boolean isDoubleEqual(double a, double b) {
    return Math.abs(a - b) < 1E-8;
}

From source file:Main.java

public static boolean isBeyondOneWeek(long timestamp) {
    return Math.abs((getServerTime() - timestamp)) > 7 * 24 * 60 * 60 * 1000;
}

From source file:Main.java

public static boolean isBeyondOneMonth(long timestamp) {
    return Math.abs((getServerTime() - timestamp)) > 30 * 24 * 60 * 60 * 1000;
}

From source file:Main.java

public static boolean isShadeOfGray(int red, int green, int blue) {
    return Math.abs(Math.max(red, Math.max(green, blue)) - Math.min(red, Math.min(green, blue))) < 20;
}

From source file:Main.java

public static int cyclicIndex(int value, int size) {
    return ((value % (size = Math.abs(size))) + size) % size;
}

From source file:Main.java

public static boolean realEqual(float a, float b, float tolerance) {
    if (Math.abs(b - a) <= tolerance)
        return true;
    else//w w  w .  j a va2s.co m
        return false;
}