Here you can find the source of clamp(float val, float max, float min)
public static float clamp(float val, float max, float min)
//package com.java2s; public class Main { public static double clamp(double val, double max, double min) { return val > max ? max : val < min ? min : val; }/*from w w w .j a va 2 s . c o m*/ public static float clamp(float val, float max, float min) { return val > max ? max : val < min ? min : val; } public static int clamp(int val, int max, int min) { return val > max ? max : val < min ? min : val; } public static long clamp(long val, long max, long min) { return val > max ? max : val < min ? min : val; } public static short clamp(short val, short max, short min) { return val > max ? max : val < min ? min : val; } public static byte clamp(byte val, byte max, byte min) { return val > max ? max : val < min ? min : val; } }