Here you can find the source of clamp(int amt, int low, int high)
Parameter | Description |
---|---|
amt | the value to constrain |
low | minimum limit |
high | maximum limit |
static public final int clamp(int amt, int low, int high)
//package com.java2s; public class Main { /**//from w ww. j av a2 s . c om * * Constrains a value to not exceed a maximum and minimum value. * * @param amt * the value to constrain * @param low * minimum limit * @param high * maximum limit */ static public final int clamp(int amt, int low, int high) { return (amt < low) ? low : ((amt > high) ? high : amt); } /** * * Constrains a value to not exceed a maximum and minimum value. * * @param amt * the value to constrain * @param low * minimum limit * @param high * maximum limit */ static public final float clamp(float amt, float low, float high) { return (amt < low) ? low : ((amt > high) ? high : amt); } /** * * Constrains a value to not exceed a maximum and minimum value. * * @param amt * the value to constrain * @param low * minimum limit * @param high * maximum limit */ static public final double clamp(double amt, double low, double high) { return (amt < low) ? low : ((amt > high) ? high : amt); } }