Here you can find the source of doubleToFloat(double d)
public static Float doubleToFloat(double d)
//package com.java2s; //License from project: LGPL public class Main { public static Float doubleToFloat(double d) { if (d >= Float.MIN_VALUE && d <= Float.MAX_VALUE) { return (float) d; }/*from ww w. j a v a2 s . c o m*/ return null; } public static float doubleToFloat(double d, float defaultValue) { if (d >= Float.MIN_VALUE && d <= Float.MAX_VALUE) { return (float) d; } return defaultValue; } }