Here you can find the source of clamp(int value, int min, int max)
static public int clamp(int value, int min, int max)
//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; } }