Here you can find the source of floatToShort(float f)
public static Short floatToShort(float f)
//package com.java2s; //License from project: LGPL public class Main { public static Short floatToShort(float f) { if (f >= Short.MIN_VALUE && f <= Short.MAX_VALUE) { return (short) f; }// w w w. j av a2s . c o m return null; } public static short floatToShort(float f, short defaultValue) { if (f >= Short.MIN_VALUE && f <= Short.MAX_VALUE) { return (short) f; } return defaultValue; } }