Java Double to Long doubleToLong(Double aVal)

Here you can find the source of doubleToLong(Double aVal)

Description

if the double can safely be converted to a Long then do it.

License

Open Source License

Parameter

Parameter Description
aVal a parameter

Declaration

public static Object doubleToLong(Double aVal) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*w w  w  . j  ava  2  s  .c o  m*/
     * if the double can safely be converted to a Long then do it.
     *
     * @param aVal
     */
    public static Object doubleToLong(Double aVal) {
        if (Double.compare(aVal, Math.ceil(aVal)) == 0) {
            return aVal.longValue();
        } else
            return aVal;
    }
}

Related

  1. doubleToLong(double d)
  2. doubleToLong(double[] values)
  3. doubleToLong(final double d)
  4. DoubleToLong_With_Little_Endian(double dd)