List of usage examples for java.lang Double equals
public boolean equals(Object obj)
From source file:org.geppetto.simulation.CustomSerializer.java
@Override public void serialize(Double value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException { if (null == value) { // write the word 'null' if there's no value available jgen.writeNull();/*from ww w . j av a 2s . c o m*/ } else if (value.equals(Double.NaN)) { jgen.writeNumber(Double.NaN); } else { final String pattern = "#.##"; final DecimalFormat myFormatter = new DecimalFormat(pattern); final String output = myFormatter.format(value).replace(",", "."); jgen.writeNumber(output); } }
From source file:com.nkapps.billing.services.NumberServiceImpl.java
@Override public String convertToText(Double number) { if (number == 0) { return "00"; }/*w w w .j av a2 s.c o m*/ String mask = "000000000000"; DecimalFormat df = new DecimalFormat(mask); String snumber = df.format(number.longValue()); int billions = Integer.parseInt(snumber.substring(0, 3)); int millions = Integer.parseInt(snumber.substring(3, 6)); int hundredThousands = Integer.parseInt(snumber.substring(6, 9)); int thousands = Integer.parseInt(snumber.substring(9, 12)); String tradBillions; switch (billions) { case 0: tradBillions = ""; break; default: tradBillions = convertLessThanOneThousand(billions) + " "; } String result = tradBillions; String tradMillions; switch (millions) { case 0: tradMillions = ""; break; default: tradMillions = convertLessThanOneThousand(millions) + " "; } result = result + tradMillions; String tradHundredThousands; switch (hundredThousands) { case 0: tradHundredThousands = ""; break; case 1: tradHundredThousands = "?? "; break; default: tradHundredThousands = convertLessThanOneThousand(hundredThousands) + " ??"; } result = result + tradHundredThousands; String tradThousand; tradThousand = convertLessThanOneThousand(thousands); result = result + tradThousand; Double tiyin = number - number.intValue(); // remove extra spaces! return result.replaceAll("^\\s+", "").replaceAll("\\b\\s{2,}\\b", " ") + " ? " + (tiyin.equals(0) ? "00" : Double.valueOf(tiyin * 100).intValue()) + " "; }
From source file:edu.cuny.qc.speech.AuToBI.core.Aggregation.java
/** * Removes a value from the Aggregation. * <p/>/*from w ww . j ava 2 s. co m*/ * Removing a value from an Aggregation can invalidate its minimum and maximum calculation if the value was equal to * the current minmum or maximum. * <p/> * Note: no check is made that the value was ever initially added to the Aggregation. * * @param v the value */ public void remove(Double v) { sum -= v; ssq -= (v * v); if (v.equals(max)) { max = Double.NaN; // no running max and min } if (v.equals(min)) { min = Double.NaN; } n--; }
From source file:ru.codemine.ccms.dao.SalesDAOImpl.java
@Override public Double getPlanCoverage(Shop shop, LocalDate startDate, LocalDate endDate) { Double plan = getPlan(shop, startDate, endDate); Double sale = getSalesValueByPeriod(shop, startDate, endDate); return plan.equals(0.0) ? 0.0 : sale / plan * 100; }
From source file:ubic.gemma.core.datastructure.matrix.MatrixConversionTest.java
public final void testColumnMapping() { Collection<QuantitationType> quantTypes = new HashSet<>(); QuantitationType quantType = PersistentDummyObjectHelper.getTestNonPersistentQuantitationType(); quantType.setId(0L);/*from w w w .j a v a2 s.c om*/ quantTypes.add(quantType); Collection<DesignElementDataVector> vectors = this.getDesignElementDataVectors(quantTypes); ExpressionDataDoubleMatrix mat = new ExpressionDataDoubleMatrix(vectors); MatrixConversionTest.log.debug(vectors.size() + " vectors"); TestCase.assertEquals(MatrixConversionTest.NUM_CS, mat.rows()); TestCase.assertEquals(MatrixConversionTest.NUM_BIOMATERIALS, mat.columns()); for (int j = 0; j < mat.rows(); j++) { // System.err.print( mat.getRowElement( j ) ); for (int i = 0; i < mat.columns(); i++) { Double r = mat.get(j, i); TestCase.assertNotNull("No value for at index " + i, r); TestCase.assertTrue("Expected " + i + ", got " + r, i == r.intValue() || r.equals(Double.NaN)); } } }
From source file:org.chiba.xml.xforms.xpath.test.ExtensionFunctionsTest.java
/** * __UNDOCUMENTED__/*from w w w . j av a 2s . c o m*/ * * @throws Exception __UNDOCUMENTED__ */ public void testAvg() throws Exception { Double avg = (Double) context.getValue("avg(/data/repeatdata/input)", Double.class); assertNotNull(avg); assertTrue(avg.equals(new Double(8.5d))); }
From source file:org.chiba.xml.xforms.xpath.test.ExtensionFunctionsTest.java
/** * __UNDOCUMENTED__//from www . j ava2 s .c o m * * @throws Exception __UNDOCUMENTED__ */ public void testMax() throws Exception { Double max = (Double) this.context.getValue("max(/data/repeatdata/input)", Double.class); assertNotNull(max); assertTrue(max.equals(new Double(20.0d))); }
From source file:org.chiba.xml.xforms.xpath.test.ExtensionFunctionsTest.java
/** * __UNDOCUMENTED__/* ww w. j av a 2 s . c o m*/ * * @throws Exception __UNDOCUMENTED__ */ public void testMin() throws Exception { Double min = (Double) this.context.getValue("min(/data/repeatdata/input)", Double.class); assertNotNull(min); assertTrue(min.equals(new Double(1.0d))); }
From source file:com.almende.eve.algorithms.test.agents.DAAAgent.java
/** * Daa receive.//ww w . j av a 2s .c o m * * @param value * the value * @throws JsonProcessingException * the json processing exception */ public synchronized void daaReceive(final @Name("value") DAAValueBean value) throws JsonProcessingException { Double oldval = 0.0; if (daa.getCurrentEstimate() != null) { oldval = daa.getCurrentEstimate().computeSum(); } daa.receive(value); if (trickle != null) { if (!oldval.equals(daa.getCurrentEstimate().computeSum())) { trickle.reset(); } else { trickle.incr(); } } }
From source file:org.haedus.datatypes.phonetic.FeatureModel.java
private Double getDifference(Double a, Double b) { if (a.equals(b)) { return 0.0; } else if (a.isNaN()) { return b; } else if (b.isNaN()) { return a; } else {//from w w w .j a v a 2s. co m return Math.abs(a - b); } }