Here you can find the source of clip(int val, int from, int to)
public static int clip(int val, int from, int to)
//package com.java2s; //License from project: Mozilla Public License public class Main { public static int clip(int val, int from, int to) { return val < from ? from : (val > to ? to : val); }//from ww w . j a v a2s . co m public static long clip(long val, long from, long to) { return val < from ? from : (val > to ? to : val); } public static float clip(float val, float from, float to) { return val < from ? from : (val > to ? to : val); } public static double clip(double val, double from, double to) { return val < from ? from : (val > to ? to : val); } public static int clip(int val, int max) { return val < max ? val : max; } }