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