Here you can find the source of clamp(float value)
public static final float clamp(float value)
//package com.java2s; //License from project: Open Source License public class Main { public static final float clamp(float value) { return clamp(value, 0f, 1f); }//from w w w . ja va 2 s . c o m public static final float clamp(float value, float min, float max) { return value > max ? max : value < min ? min : value; } }