Java Double to Short doubleToShort(double d)

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

Description

double To Short

License

LGPL

Declaration

public static Short doubleToShort(double d) 

Method Source Code

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

Related

  1. doubleToShort(double[] values)
  2. doubleToShort(final double value)
  3. doubleToShortBits(double d)