Java Double to Float doubleToFloat(double d)

Here you can find the source of doubleToFloat(double d)

Description

double To Float

License

LGPL

Declaration

public static Float doubleToFloat(double d) 

Method Source Code

//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;
    }
}

Related

  1. doubleToFloat(double[] array)
  2. doubleToFloat(double[] array)
  3. doubleToFloat(final double value)