Here you can find the source of clamp(double min, double value, double max)
public static double clamp(double min, double value, double max)
//package com.java2s; public class Main { /**//from w w w . j a v a 2 s . c o m * Simple utility function which clamps the given value to be strictly * between the min and max values. */ public static double clamp(double min, double value, double max) { if (value < min) return min; if (value > max) return max; return value; } }