Here you can find the source of doubleToShort(double d)
public static Short doubleToShort(double d)
//package com.java2s; //License from project: LGPL public class Main { public static Short doubleToShort(double d) { if (d >= Short.MIN_VALUE && d <= Short.MAX_VALUE) { return (short) d; }//from w w w. java2 s .c o m return null; } public static short doubleToShort(double d, short defaultValue) { if (d >= Short.MIN_VALUE && d <= Short.MAX_VALUE) { return (short) d; } return defaultValue; } }