Here you can find the source of clamp(int a)
public static int clamp(int a)
//package com.java2s; //License from project: LGPL public class Main { public static int clamp(int a) { if (a < 0) { return 0; } else if (a > 0xff) { return 0xff; }/*from ww w . j a v a 2 s . com*/ return a; } public static double clamp(double a) { if (a < 0) { return 0; } else if (a > 0xff) { return 0xff; } return a; } }