Java Integer Clamp clamp(int min, int val, int max)

Here you can find the source of clamp(int min, int val, int max)

Description

clamp

License

Apache License

Declaration

public static int clamp(int min, int val, int max) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

public class Main {
    public static int clamp(int min, int val, int max) {
        return Math.min(Math.max(val, min), max);
    }/*from  w  w w  .j a v a  2  s .  co m*/

    public static double clamp(double min, double val, double max) {
        return Math.min(Math.max(val, min), max);
    }

    public static double min(double... values) {
        double min = Double.MAX_VALUE;
        for (double v : values) {
            min = Math.min(v, min);
        }
        return min;
    }

    public static double max(double... values) {
        double max = Double.MIN_VALUE;
        for (double v : values) {
            max = Math.max(v, max);
        }
        return max;
    }
}

Related

  1. clamp(int c)
  2. clamp(int c)
  3. clamp(int floor, int ceiling, int value)
  4. clamp(int i, int low, int high)
  5. clamp(int i, int min, int max)
  6. clamp(int min, int value, int max)
  7. clamp(int n, int l, int u)
  8. clamp(int n, int lower, int upper)
  9. clamp(int n, int min, int max)