List of usage examples for java.lang Number doubleValue
public abstract double doubleValue();
From source file:jasima.core.util.ExperimentTest.java
/** * Checks if all keys in <code>resExpected</code> are also present in * <code>resActual</code> and have the same values. Additional keys in * <code>resActual</code> as well as the key <code>"runTime"</code> are * ignored.//from www. java 2 s . co m * * @param resActual * The map of results actually obtained. * @param resExpected * The map of expected results. */ protected void checkResults(Map<String, Object> resActual, Map<String, Object> resExpected) { for (String name : resExpected.keySet()) { if (Experiment.RUNTIME.equals(name) || name.endsWith("." + Experiment.RUNTIME)) continue; errorCollector.checkThat(name, resActual.keySet(), hasItem(name)); Object expected = resExpected.get(name); Object actual = resActual.get(name); if (actual == null) continue; name = "result entry '" + name + "'"; if (expected instanceof SummaryStat) { checkValueStat(name, (SummaryStat) expected, (SummaryStat) actual); } else if (expected instanceof Double) { Number exp = (Number) expected; Number act = (Number) actual; checkDouble(name, act.doubleValue(), exp.doubleValue()); } else if (expected instanceof Double) { Number exp = (Number) expected; Number act = (Number) actual; checkDouble(name, act.doubleValue(), exp.doubleValue()); } else errorCollector.checkThat(name, actual, is(expected)); } }
From source file:playground.thibautd.utils.charts.TwoCategoriesBoxAndWhiskerChart.java
public void addItem(final List<? extends Number> itemData, final Comparable<?> rowKey, final Comparable<?> columnKey) { dataset.add(itemData, rowKey, columnKey); if (plotStdDev) { double average = 0; double stdDev = 0; int count = 0; for (Number num : itemData) { count++;//ww w. j av a2 s . c o m average += num.doubleValue(); } average /= count; double current; for (Number num : itemData) { current = num.doubleValue() - average; current *= current; stdDev += current; } stdDev /= count; stdDev = Math.sqrt(stdDev); errorBarsDataset.add(average, stdDev, rowKey, columnKey); } }
From source file:ijfx.service.overlay.io.OverlaySerializer.java
private void writeNumberArray(JsonGenerator jg, String arrayName, Number[] numbers) throws IOException { jg.writeFieldName(arrayName);// ww w. j a va 2 s .co m jg.writeStartArray(); for (Number n : numbers) { jg.writeNumber(n.doubleValue()); } jg.writeEndArray(); }
From source file:com.thinkbiganalytics.policy.validation.RangeValidator.java
public RangeValidator(@PolicyPropertyRef(name = "Min") Number min, @PolicyPropertyRef(name = "Max") Number max) { super();/* w w w. j av a 2 s.c o m*/ this.min = (min != null ? min.doubleValue() : null); this.max = (max != null ? max.doubleValue() : null); if (min != null && max != null) { Validate.isTrue(this.min <= this.max, "Minimum must smaller than Maximum"); } }
From source file:net.jofm.format.NumberFormat.java
private Object convert(Number result, Class<?> destinationClazz) { if (destinationClazz.equals(BigDecimal.class)) { return new BigDecimal(result.doubleValue()); }/*from w ww. j a v a 2s .c o m*/ if (destinationClazz.equals(Short.class) || destinationClazz.equals(short.class)) { return new Short(result.shortValue()); } if (destinationClazz.equals(Integer.class) || destinationClazz.equals(int.class)) { return new Integer(result.intValue()); } if (destinationClazz.equals(Long.class) || destinationClazz.equals(long.class)) { return new Long(result.longValue()); } if (destinationClazz.equals(Float.class) || destinationClazz.equals(float.class)) { return new Float(result.floatValue()); } if (destinationClazz.equals(Double.class) || destinationClazz.equals(double.class)) { return new Double(result.doubleValue()); } throw new FixedMappingException("Unable to parse the data to type " + destinationClazz.getName() + " using " + this.getClass().getName()); }
From source file:net.sf.zekr.common.util.VelocityUtils.java
public double mul(Object num1, Object num2) { Number n1 = toDouble(num1); Number n2 = toDouble(num2);// w w w .j a v a2 s. c om double value = n1.doubleValue() * n2.doubleValue(); return value; }
From source file:net.sf.zekr.common.util.VelocityUtils.java
public double div1(Object num1, Object num2) { Number n1 = toDouble(num1); Number n2 = toDouble(num2);/*from ww w. ja v a 2s. co m*/ double value = n1.doubleValue() / n2.doubleValue(); return ((int) (value * 10)) / 10.0; }
From source file:ch.unibe.iam.scg.archie.ui.charts.HistogramTooltipGenerator.java
/** * @{inheritDoc// ww w . j av a 2s .c o m */ @Override protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { Object[] result = new Object[4]; String nullValueString = "-"; result[0] = dataset.getRowKey(row).toString(); result[1] = dataset.getColumnKey(column).toString(); Number value = dataset.getValue(row, column); if (value != null) { // flip negative numbers result[2] = value.doubleValue() < 0 ? -value.doubleValue() : value.doubleValue(); } else { result[2] = nullValueString; } return result; }
From source file:com.exxonmobile.ace.hybris.storefront.forms.validation.B2BBudgetFormValidator.java
@Override public void validate(final Object object, final Errors errors) { final B2BBudgetForm form = (B2BBudgetForm) object; final String budget = form.getBudget(); if (StringUtils.isBlank(budget)) { errors.rejectValue("budget", "general.required"); } else {//from www.ja v a 2 s .c o m final Number budgetNumber; try { budgetNumber = getFormatFactory().createNumberFormat().parse(budget); if (budgetNumber.doubleValue() < 0D) { errors.rejectValue("budget", "text.company.manageBudgets.budget.invalid"); } } catch (final ParseException e) { errors.rejectValue("budget", "text.company.manageBudgets.budget.invalid"); } } }
From source file:de.tuberlin.uebb.jbop.optimizer.utils.NodeHelper.java
private static AbstractInsnNode getDoubleInsnNode(final Number newNumber) { if (newNumber.doubleValue() == 0) { return new InsnNode(Opcodes.DCONST_0); } else if (newNumber.doubleValue() == 1) { return new InsnNode(Opcodes.DCONST_1); } else {//from ww w.jav a 2s .c o m return new LdcInsnNode(newNumber); } }