Here you can find the source of clampRoundShort(double in)
public static final short clampRoundShort(double in)
//package com.java2s; /*//from w w w . j a va 2s . c o m * $RCSfile: ImageUtil.java,v $ * * Copyright (c) 2005 Sun Microsystems, Inc. All rights reserved. * * Use is subject to license terms. * * $Revision: 1.2 $ * $Date: 2006/07/21 20:53:28 $ * $State: Exp $ */ public class Main { /** * Clamps and rounds a number to the range supported by * short data type. The input number is float. */ public static final short clampRoundShort(float in) { return (in > Short.MAX_VALUE ? Short.MAX_VALUE : (in >= Short.MIN_VALUE ? (short) Math.floor(in + 0.5F) : Short.MIN_VALUE)); } /** * Clamps and rounds a number to the range supported by * short data type. The input number is double. */ public static final short clampRoundShort(double in) { return (in > Short.MAX_VALUE ? Short.MAX_VALUE : (in >= Short.MIN_VALUE ? (short) Math.floor(in + 0.5) : Short.MIN_VALUE)); } }