Example usage for java.lang Integer doubleValue

List of usage examples for java.lang Integer doubleValue

Introduction

In this page you can find the example usage for java.lang Integer doubleValue.

Prototype

public double doubleValue() 

Source Link

Document

Returns the value of this Integer as a double after a widening primitive conversion.

Usage

From source file:Main.java

public static void main(String[] args) {
    Integer integerObject = new Integer("1234567");

    double d = integerObject.doubleValue();
    System.out.println("double:" + d);

}

From source file:Main.java

public static void main(String[] args) {
    Integer intObj = Integer.valueOf(100);

    // Gets byte from Integer
    byte b = intObj.byteValue();

    // Gets double from Integer
    double dd = intObj.doubleValue();
    System.out.println("intObj = " + intObj);
    System.out.println("byte from  intObj = " + b);
    System.out.println("double from  intObj = " + dd);

    // Creates a Double object
    Double doubleObj = Double.valueOf("123.45");

    // Gets different types of primitive values from Double
    double d = doubleObj.doubleValue();
    float f = doubleObj.floatValue();
    int i = doubleObj.intValue();
    long l = doubleObj.longValue();

    System.out.println("doubleObj = " + doubleObj);
    System.out.println("double from  doubleObj   = " + d);
    System.out.println("float from  doubleObj   = " + f);
    System.out.println("int from  doubleObj   = " + i);
    System.out.println("long from  doubleObj   = " + l);
}

From source file:Main.java

public static void main(String[] args) {
    Integer intObj = new Integer("10");
    byte b = intObj.byteValue();
    System.out.println(b);//from   w  w w  .j  a  va 2s .c  o m

    short s = intObj.shortValue();
    System.out.println(s);

    int i = intObj.intValue();
    System.out.println(i);

    float f = intObj.floatValue();
    System.out.println(f);

    double d = intObj.doubleValue();
    System.out.println(d);
}

From source file:PerformanceGraph.java

/**
 * Plots the performance graph of the best fitness value so far versus the
 * number of function calls (NFC).//  w ww .  j av a  2s  . c  om
 * 
 * @param bestFitness A linked hashmap mapping the NFC to the best fitness value
 * found so far.
 * @param fitnessFunction The name of the fitness function, used for the title and the
 * name of the file that is saved, e.g. "De Jong".
 */
public static void plot(LinkedHashMap<Integer, Double> bestFitness, String fitnessFunction) {
    /* Create an XYSeries plot */
    XYSeries series = new XYSeries("Best Fitness Value Vs. Number of Function Calls");

    /* Add the NFC and best fitness value data to the series */
    for (Integer NFC : bestFitness.keySet()) {
        /* Jfreechart crashes if double values are too large! */
        if (bestFitness.get(NFC) <= 10E12) {
            series.add(NFC.doubleValue(), bestFitness.get(NFC).doubleValue());
        }
    }

    /* Add the x,y series data to the dataset */
    XYSeriesCollection dataset = new XYSeriesCollection();
    dataset.addSeries(series);

    /* Plot the data as an X,Y line chart */
    JFreeChart chart = ChartFactory.createXYLineChart("Best Fitness Value Vs. Number of Function Calls",
            "Number of Function Calls (NFC)", "Best Fitness Value", dataset, PlotOrientation.VERTICAL, false,
            true, false);

    /* Configure the chart settings such as anti-aliasing, background colour */
    chart.setAntiAlias(true);

    XYPlot plot = chart.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.black);
    plot.setDomainGridlinePaint(Color.black);

    /* Set the domain range from 0 to NFC */
    NumberAxis domain = (NumberAxis) plot.getDomainAxis();
    domain.setRange(0.0, ControlVariables.MAX_FUNCTION_CALLS.doubleValue());

    /* Logarithmic range axis */
    plot.setRangeAxis(new LogAxis());

    /* Set the thickness and colour of the lines */
    XYItemRenderer renderer = plot.getRenderer();
    BasicStroke thickLine = new BasicStroke(3.0f);
    renderer.setSeriesStroke(0, thickLine);
    renderer.setPaint(Color.BLACK);

    /* Display the plot in a JFrame */
    ChartFrame frame = new ChartFrame(fitnessFunction + " Best Fitness Value", chart);
    frame.setVisible(true);
    frame.setSize(1000, 600);

    /* Save the plot as an image named after fitness function
    try
    {
       ChartUtilities.saveChartAsJPEG(new File("plots/" + fitnessFunction + ".jpg"), chart, 1600, 900);
    }
    catch (IOException e)
    {
       e.printStackTrace();
    }*/
}

From source file:com.glaf.core.util.ParamUtils.java

public static Double getDoubleValue(Map<String, Object> dataMap, String key) {
    Double result = null;//from w  w  w . java  2s.  co  m
    Object value = dataMap.get(key);
    if (value == null) {
        value = dataMap.get(key.toLowerCase());
    }
    if (value == null) {
        value = dataMap.get(key.toUpperCase());
    }
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Double.parseDouble(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.doubleValue();
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.doubleValue();
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.doubleValue();
        } else {
            String tmp = value.toString();
            result = Double.parseDouble(tmp);
        }
    } else {
        result = MapUtils.getDouble(dataMap, key);
    }
    return result;
}

From source file:com.glaf.core.util.ParamUtils.java

public static double getDouble(Map<String, Object> dataMap, String key) {
    double result = 0.0D;
    Object value = dataMap.get(key);
    if (value == null) {
        value = dataMap.get(key.toLowerCase());
    }/*from  w  ww.  j a v a 2s  . c  om*/
    if (value == null) {
        value = dataMap.get(key.toUpperCase());
    }

    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Double.parseDouble(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.doubleValue();
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.doubleValue();
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.doubleValue();
        } else {
            String tmp = value.toString();
            result = Double.parseDouble(tmp);
        }
    } else {
        result = MapUtils.getDoubleValue(dataMap, key);
    }

    return result;
}

From source file:com.inkubator.common.util.DateTimeUtil.java

/**
 * get total times (Age) based on date parameter and calculate with total
 * difference of month//from  ww w.  j a  va 2 s.co  m
 *
 * @param birthDate input date type
 * @return Double age that calculate from today.
 * @throws java.lang.Exception
 *
 */
public static Double getAgeWithMonth(Date birthDate) throws Exception {
    Integer age = getAge(birthDate);
    Integer totalMonth = getTotalMonthDifference(birthDate, new Date());
    Integer totalMonthDifference = totalMonth - (12 * age);
    return age.doubleValue() + (totalMonthDifference.doubleValue() / 12);
}

From source file:com.github.jessemull.microflex.util.IntegerUtil.java

/**
 * Converts a list of integers to a list of doubles.
 * @param    List<Integer>    the list of integers
 * @return                    the list of doubles
 *///from w w  w .java  2 s .  c  o  m
public static List<Double> toDoubleList(List<Integer> list) {
    List<Double> doubleList = new ArrayList<Double>();
    for (Integer val : list) {
        doubleList.add(val.doubleValue());
    }
    return doubleList;
}

From source file:com.glaf.base.utils.ParamUtil.java

public static double getDouble(Map<String, Object> dataMap, String key) {
    double result = 0.0;
    Object value = dataMap.get(key);
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Double.valueOf(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.doubleValue();
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.doubleValue();//from ww  w  .j ava 2s .  co  m
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.doubleValue();
        }
    }
    return result;
}

From source file:org.xbasej.Util.java

public static double doubleDate(String s) {
    int i;/*from ww w.  java  2s  .c  om*/

    if (s.trim().length() == 0)
        return 1e100;

    int year = Integer.parseInt(s.substring(0, 4));
    if (year == 0)
        return 1e100;

    int days[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    int month = Integer.parseInt(s.substring(4, 6));
    int day = Integer.parseInt(s.substring(6, 8));

    int daydif = 2378497;

    if ((year / 4) == 0)
        days[2] = 29;

    if (year > 1799) {
        daydif += day - 1;
        for (i = 2; i <= month; i++)
            daydif += days[i - 1];
        daydif += (year - 1800) * 365;
        daydif += ((year - 1800) / 4);
        daydif -= ((year - 1800) % 100); // leap years don't occur in 00
                                         // years
        if (year > 1999) // except in 2000
            daydif++;
    } else {
        daydif -= (days[month] - day + 1);
        for (i = 11; i >= month; i--)
            daydif -= days[i + 1];
        daydif -= (1799 - year) * 365;
        daydif -= (1799 - year) / 4;
    }

    Integer retInt = new Integer(daydif);

    return retInt.doubleValue();
}