List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:Main.java
/** * Sums up all the associated values from the specified * <code>map</code>//from w w w.ja v a 2s . c om * @param map * @return */ public static <K> double sum(Map<K, ? extends Number> map) { double sum = 0.0; for (Number value : map.values()) { sum += value.doubleValue(); } return sum; }
From source file:Main.java
static public double[] toDoubleArray(ArrayList list) { double[] result = new double[list.size()]; for (int i = 0; i < list.size(); i++) { Number n = (Number) list.get(i); result[i] = n.doubleValue(); }/*w ww . java 2s.c om*/ return result; }
From source file:Main.java
public static List<Double> toDoubles(Collection<? extends Number> numbers) { List<Double> result = new ArrayList<Double>(); for (Number number : numbers) { result.add(number.doubleValue()); }/* www . ja va 2 s . co m*/ return result; }
From source file:Main.java
public static Double sub(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.subtract(b2).doubleValue(); }
From source file:Main.java
public static int compareTo(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.compareTo(b2); }
From source file:Main.java
public static Double mul(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.multiply(b2).doubleValue(); }
From source file:Main.java
public static Double add(Number value1, Number value2) { BigDecimal b1 = new BigDecimal(Double.toString(value1.doubleValue())); BigDecimal b2 = new BigDecimal(Double.toString(value2.doubleValue())); return b1.add(b2).doubleValue(); }
From source file:Main.java
public static int getMatchingThresholdFromString(String value) throws ParseException { char percent = new DecimalFormatSymbols().getPercent(); value = value.replace(percent, ' '); Number number = NumberFormat.getNumberInstance().parse(value); double parse = number.doubleValue(); double p = Math.log10(Math.max(Double.MIN_VALUE, Math.min(1, parse / 100))); return Math.max(0, (int) Math.round(-12 * p)); }
From source file:Main.java
private static void subtract(final List<Double> result, final Object o1, final Object o2) { final Number val1 = (Number) o1; final Number val2 = (Number) o2; result.add(val1.doubleValue() - val2.doubleValue()); }
From source file:fr.eo.util.dumper.JSONDumper.java
private static Object getFieldValue(RequestDefinitionBean request, int pos, ResultSet rs, String fieldName) throws SQLException { String str = String.valueOf(rs.getObject(fieldName)).trim(); if (str.endsWith(".0")) { str = str.substring(0, str.length() - 2); }/*w w w . ja v a 2 s. c o m*/ if (str.equals("null") || str.isEmpty()) { return null; } if (request.compressedStrPos.contains(pos)) { str = getCompressedString(str); } else if (request.numberPos.contains(pos)) { Number number = rs.getDouble(fieldName); if (number.longValue() == number.doubleValue()) { return number.longValue(); } return number.doubleValue(); } else if (request.fieldStrPos.contains(pos)) { str = formatString(str); } return str; }