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

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

Description

clamp

License

Open Source License

Declaration

public static final int clamp(int x, int min, int max) 

Method Source Code

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

public class Main {
    public static final int clamp(int x, int min, int max) {
        if (x > max)
            return max;
        if (x > min)
            return x;
        return min;
    }//from   w  w  w .  j  a  v a  2s . c om

    public static final float clamp(float x, float min, float max) {
        if (x > max)
            return max;
        if (x > min)
            return x;
        return min;
    }

    public static final double clamp(double x, double min, double max) {
        if (x > max)
            return max;
        if (x > min)
            return x;
        return min;
    }
}

Related

  1. clamp(int value, int min, int max)
  2. clamp(int value, int min, int max)
  3. clamp(int value, int minValue, int maxValue)
  4. clamp(int var, int min, int max)
  5. clamp(int x, int min, int max)
  6. clamp(String string, int maxChars)
  7. clamp_int(int num, int min, int max)
  8. clamp_wrap(int a, int x, int y)
  9. clampAngle(int angle)