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

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

Description

clamp

License

Open Source License

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static int clamp(int min, int value, int max) {
        return Math.min(max, Math.max(min, value));
    }//from   w ww  . j a  v  a2  s  . c  om

    public static long clamp(long min, long value, long max) {
        return Math.min(max, Math.max(min, value));
    }

    public static float clamp(float min, float value, float max) {
        return Math.min(max, Math.max(min, value));
    }

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

Related

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