Here you can find the source of clamp(double val, double min, double max)
public static double clamp(double val, double min, double max)
//package com.java2s; //License from project: LGPL public class Main { public static double clamp(double val, double min, double max) { return Math.max(min, Math.min(max, val)); }//from www . j a v a 2 s . c o m public static float clamp(float val, float min, float max) { return Math.max(min, Math.min(max, val)); } public static int clamp(int val, int min, int max) { return Math.max(min, Math.min(max, val)); } }