Here you can find the source of clamp(double a, double min, double max)
public static double clamp(double a, double min, double max)
//package com.java2s; /**/* www . j a va 2 s . com*/ * Part of campskeleton: http://code.google.com/p/campskeleton/ * * Original Copyright Notice: http://www.apache.org/licenses/LICENSE-2.0 * * * @author twak */ public class Main { public static double clamp(double a, double min, double max) { return a < min ? min : a > max ? max : a; } public static int clamp(int a, int min, int max) { return a < min ? min : a > max ? max : a; } }