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

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

Description

clamp

License

Open Source License

Declaration

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

Method Source Code

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

public class Main {
    public static int clamp(int value, int min, int max) {
        if (value < min)
            return min;

        if (value > max)
            return max;

        return value;
    }//from w w w.ja  va  2s .c  om

    public static float clamp(float value, float min, float max) {
        if (value < min)
            return min;

        if (value > max)
            return max;

        return value;
    }

    public static double clamp(double value, double min, double max) {
        if (value < min)
            return min;

        if (value > max)
            return max;

        return value;
    }

    public static long clamp(long value, long min, long max) {
        if (value < min)
            return min;

        if (value > max)
            return max;

        return value;
    }
}

Related

  1. clamp(int value, int min, int max)
  2. clamp(int value, int min, int max)
  3. clamp(int value, int min, int max)
  4. clamp(int value, int min, int max)
  5. clamp(int value, int min, int max)
  6. clamp(int value, int minValue, int maxValue)
  7. clamp(int var, int min, int max)
  8. clamp(int x, int min, int max)
  9. clamp(int x, int min, int max)