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 isEqualLarge2(int currentX, int currentY, int lastX, int lastY) {
    if (Math.abs(currentX - lastX) < 100 && Math.abs(currentY - lastY) < 100) {
        return true;
    }/*ww w .  j  a  va  2s.c  o m*/
    return false;
}

From source file:Main.java

public static String genPic(int code) {
    return "http://och7s33jc.bkt.clouddn.com/cover_" + (300 + (Math.abs(code) % 30)) + ".jpg";
}

From source file:Main.java

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

From source file:Main.java

private static int getSizeGap(Size size, int wantSize) {
    return Math.abs(size.width * size.height - wantSize);
}

From source file:Main.java

private static int getWidthGap(Size size, int wantWidth) {
    return Math.abs(size.height - wantWidth);
}

From source file:Main.java

public static int absDirectionDiff(int a, int b) {
    //      ABS(180 - ABS(180- ABS(A - B))) 
    return Math.abs(180 - Math.abs(180 - Math.abs(a - b)));
}

From source file:Main.java

public static float angleInDegrees(float ownerRotation, float x1, float y1, float x2, float y2) {
    return Math.abs(ownerRotation - angleInDegrees(x1, y1, x2, y2)) % 360;
}

From source file:Main.java

public static float abs(float x) {
    return Math.abs(x);
}

From source file:Main.java

public static int getColor(float barValue) {

    barValue = Math.abs(barValue);

    if (barValue < 50) {
        return Color.GREEN;
    } else if (barValue >= 50 && barValue <= 100) {
        return Color.BLUE;
    } else if (barValue > 100 && barValue <= 200) {
        return Color.YELLOW;
    }/* w w w . j a v a2 s .  co m*/
    return Color.RED;
}

From source file:Main.java

public static int timeSpanInDays(Calendar cal1, Calendar cal2) {
    return (int) ((Math.abs(cal1.getTimeInMillis() - cal2.getTimeInMillis())) / (1000 * 60 * 60 * 24));
}