Here you can find the source of clamp(double value, double low, double high)
public static double clamp(double value, double low, double high)
//package com.java2s; //License from project: LGPL public class Main { public static double clamp(double value, double low, double high) { if (value < low) { return low; }/*from www. ja va 2s. c o m*/ if (value > high) { return high; } return value; } public static int clamp(int value, int low, int high) { if (value < low) { return low; } if (value > high) { return high; } return value; } }