Here you can find the source of clamp255d(double d)
public static int clamp255d(double d)
//package com.java2s; /*/*from w ww.ja v a 2 s . c o m*/ * JaamSim Discrete Event Simulation * Copyright (C) 2012 Ausenco Engineering Canada Inc. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ public class Main { public static int clamp255d(double d) { return clamp255((int) d); } public static int clamp255(int i) { if (i < 0) return 0; if (i > 255) return 255; return i; } }