Example usage for java.lang Math min

List of usage examples for java.lang Math min

Introduction

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

Prototype

@HotSpotIntrinsicCandidate
public static double min(double a, double b) 

Source Link

Document

Returns the smaller of two double values.

Usage

From source file:Main.java

public static int randomLow(int max) {
    return Math.min(random(max), random(max));
}

From source file:Main.java

public static int lightenColor(int color) {
    return Color.rgb(Math.min(Color.red(color) + 50, 255), Math.min(Color.green(color) + 50, 255),
            Math.min(Color.blue(color) + 50, 255));
}

From source file:Main.java

public static int minDigit(int n) {
    return n == 0 ? 0 : Math.min(n % 10, minDigit(n / 10));
}

From source file:Main.java

public static float limitValue(float a, float b) {
    float valve = 0;
    final float min = Math.min(a, b);
    final float max = Math.max(a, b);
    valve = valve > min ? valve : min;
    valve = valve < max ? valve : max;
    return valve;
}

From source file:Main.java

private static int min(int first, int second, int third) {
    return Math.min(first, Math.min(second, third));
}

From source file:Main.java

public static int lighterColor(int color, int lighter) {
    int r = Math.max(Math.min(Color.red(color) + lighter, 255), 0);
    int g = Math.max(Math.min(Color.green(color) + lighter, 255), 0);
    int b = Math.max(Math.min(Color.blue(color) + lighter, 255), 0);
    return Color.rgb(r, g, b);
}

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 void applyDiagSlice(int[][] matrix, int row, int column, boolean forwards, int[] slice) {
    int sliceSize = Math.min(matrix.length - row, forwards ? matrix[0].length - column : column + 1);
    for (int i = 0; i < sliceSize; i++) {
        int columnIdx = forwards ? i : -i;
        matrix[row + i][column + columnIdx] = slice[i];
    }/* w  w w. j av  a2  s  . c o m*/
}

From source file:Main.java

public static int colsToInt(int r, int g, int b, int a) {
    return (Math.max(Math.min(a, 255), 0) << 24) + (Math.max(Math.min(r, 255), 0) << 16)
            + (Math.max(Math.min(g, 255), 0) << 8) + Math.max(Math.min(b, 255), 0);
}

From source file:Main.java

public static void diagSlice(int[][] matrix, int row, int column, boolean forwards, int[] slice) {
    int sliceSize = Math.min(matrix.length - row, forwards ? matrix[0].length - column : column + 1);
    for (int i = 0; i < sliceSize; i++) {
        int columnIdx = forwards ? i : -i;
        slice[i] = matrix[row + i][column + columnIdx];
    }/*from w ww  .  jav  a 2s .  c o  m*/
    for (int i = sliceSize; i < slice.length; i++) {
        slice[i] = 0;
    }
}