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

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

Method Source Code

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

public class Main {
    static public int clamp(int value, int min, int max) {
        if (value < min) {
            return min;
        }// w  ww  . j a v a2 s.com
        if (value > max) {
            return max;
        }
        return value;
    }

    static public short clamp(short value, short min, short max) {
        if (value < min) {
            return min;
        }
        if (value > max) {
            return max;
        }
        return value;
    }

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

Related

  1. clamp(int value, int low, int high)
  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 min, int max)
  7. clamp(int value, int min, int max)
  8. clamp(int value, int min, int max)
  9. clamp(int value, int minValue, int maxValue)