List of usage examples for java.lang Number intValue
public abstract int intValue();
From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java
private AbstractInsnNode handleDiv(final int opcode, final Number one, final Number two) { final Number number; switch (opcode) { case IDIV:/* w w w .j ava2 s. c om*/ number = Integer.valueOf(one.intValue() / two.intValue()); break; case DDIV: number = Double.valueOf(one.doubleValue() / two.doubleValue()); break; case FDIV: number = Float.valueOf(one.floatValue() / two.floatValue()); break; case LDIV: number = Long.valueOf(one.longValue() / two.longValue()); break; default: return null; } return NodeHelper.getInsnNodeFor(number); }
From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java
private AbstractInsnNode handleMul(final int opcode, final Number one, final Number two) { final Number number; switch (opcode) { case IMUL://from w ww .j a va 2 s. c o m number = Integer.valueOf(one.intValue() * two.intValue()); break; case DMUL: number = Double.valueOf(one.doubleValue() * two.doubleValue()); break; case FMUL: number = Float.valueOf(one.floatValue() * two.floatValue()); break; case LMUL: number = Long.valueOf(one.longValue() * two.longValue()); break; default: return null; } return NodeHelper.getInsnNodeFor(number); }
From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java
private AbstractInsnNode handleSub(final int opcode, final Number one, final Number two) { final Number number; switch (opcode) { case ISUB://from ww w .j a v a 2s. com number = Integer.valueOf(one.intValue() - two.intValue()); break; case DSUB: number = Double.valueOf(one.doubleValue() - two.doubleValue()); break; case FSUB: number = Float.valueOf(one.floatValue() - two.floatValue()); break; case LSUB: number = Long.valueOf(one.longValue() - two.longValue()); break; default: return null; } return NodeHelper.getInsnNodeFor(number); }
From source file:de.tuberlin.uebb.jbop.optimizer.arithmetic.ArithmeticExpressionInterpreter.java
private AbstractInsnNode handleAdd(final int opcode, final Number one, final Number two) { final Number number; switch (opcode) { case IADD://from w w w. j av a2 s . c o m number = Integer.valueOf(one.intValue() + two.intValue()); break; case DADD: number = Double.valueOf(one.doubleValue() + two.doubleValue()); break; case FADD: number = Float.valueOf(one.floatValue() + two.floatValue()); break; case LADD: number = Long.valueOf(one.longValue() + two.longValue()); break; default: return null; } return NodeHelper.getInsnNodeFor(number); }
From source file:io.coala.random.impl.RandomDistributionFactoryImpl.java
@Override public RandomNumberDistribution<Integer> getZipf(final RandomNumberStream rng, final Number numberOfElements, final Number exponent) { final IntegerDistribution dist = new ZipfDistribution(RandomNumberStream.Util.asCommonsRandomGenerator(rng), numberOfElements.intValue(), exponent.doubleValue()); return new RandomNumberDistribution<Integer>() { @Override//from w w w . ja v a2 s.c o m public Integer draw() { return dist.sample(); } }; }
From source file:org.openmrs.module.webservices.rest.web.v1_0.controller.PersonNameControllerTest.java
@Test public void shouldPurgeName() throws Exception { // I'm using sql queries and a flush-session because if I try to test this the natural way, hibernate // complains that the name will be re-created since the person is in the session. Number before = (Number) Context.getAdministrationService() .executeSQL("select count(*) from person_name where person_id = 1", true).get(0).get(0); controller.purge(personUuid, nameUuid, request, response); Context.flushSession();// w w w .j a v a 2 s . c om Number after = (Number) Context.getAdministrationService() .executeSQL("select count(*) from person_name where person_id = 1", true).get(0).get(0); Assert.assertEquals(before.intValue() - 1, after.intValue()); Assert.assertNull(service.getPersonNameByUuid(nameUuid)); }
From source file:org.brushingbits.jnap.persistence.hibernate.Dao.java
/** * //from w w w.ja va2 s . c o m * @param query * @return */ protected Integer count(Query query) { if (!query.getQueryString().toLowerCase().startsWith("select count(")) { throw new QuerySyntaxException("The count query must start with a 'select count clause'", query.getQueryString()); } Number quantity = (Number) query.uniqueResult(); return quantity == null ? 0 : quantity.intValue(); }
From source file:com.diversityarrays.kdxplore.stats.IntegerSimpleStatistics.java
public IntegerSimpleStatistics(String statsName, List<KdxSample> sampleMeasurements, Integer nStdDevForOutlier, NumericTraitValidationProcessor tvp) { super(statsName, Integer.class); nSampleMeasurements = sampleMeasurements.size(); long sum = 0; @SuppressWarnings("unused") double ssq = 0; Bag<String> svalues = new HashBag<String>(); List<Integer> values = new ArrayList<>(nSampleMeasurements); for (KdxSample sm : sampleMeasurements) { String traitValue = sm.getTraitValue(); switch (TraitValue.classify(traitValue)) { case NA:/*from ww w . j a va2 s . c o m*/ ++nNA; break; case SET: Either<TraitValueType, Number> either = tvp.isTraitValueValid(traitValue); if (either.isRight()) { try { Number number = either.right(); if (number == null) { ++nMissing; } else { int i = number.intValue(); sum += i; ssq += i * 1.0 * i; values.add(i); svalues.add(String.valueOf(i)); } } catch (NumberFormatException e) { ++nInvalid; } } else { ++nInvalid; } break; case MISSING: case UNSET: default: ++nMissing; break; } } nValidValues = values.size(); switch (nValidValues) { case 0: mean = null; mode = null; median = null; minValue = null; maxValue = null; variance = null; stddev = null; nOutliers = null; stderr = null; break; case 1: mean = values.get(0).intValue(); mode = mean.toString(); median = mean; minValue = mean; maxValue = mean; variance = null; stddev = null; nOutliers = null; stderr = null; break; default: mean = (int) sum / nValidValues; if (USE_TWO_PASS) { double s2 = 0; for (Number n : values) { double i = n.doubleValue(); s2 += (i - mean) * (i - mean); } variance = s2 / (nValidValues - 1); } else { variance = (ssq - (sum * sum) / nValidValues) / (nValidValues - 1); } stddev = Math.sqrt(variance); stderr = stddev / Math.sqrt(nValidValues); Collections.sort(values); minValue = values.get(0).intValue(); maxValue = values.get(values.size() - 1).intValue(); median = StatsUtil.computeIntegerMedian(values); List<String> modes = StatsUtil.computeMode(svalues, tvp); String numberFormat = tvp == null ? null : tvp.getStringNumberFormat(); StringBuilder sb = new StringBuilder(); String sep = ""; for (String s : modes) { sb.append(sep); if (tvp == null) { sb.append(s); } else { Either<TraitValueType, Number> either = tvp.isTraitValueValid(s); if (either.isRight()) { Number number = either.right(); if (Integer.class.isAssignableFrom(tvp.getNumberClass())) { sb.append(number.intValue()); } else if (numberFormat == null) { sb.append(s); } else { sb.append(number.intValue()); } } else { sb.append(s); } } sep = " , "; } mode = sb.toString(); double q1 = BoxAndWhiskerCalculator.calculateQ1(values); double q3 = BoxAndWhiskerCalculator.calculateQ3(values); quartile1 = (int) Math.round(q1); quartile3 = (int) Math.round(q3); if (nStdDevForOutlier == null) { double interQuartileRange = q3 - q1; double lowerOutlierThreshold = q1 - (interQuartileRange * 1.5); double upperOutlierThreshold = q3 + (interQuartileRange * 1.5); collectOutliers(values, lowerOutlierThreshold, upperOutlierThreshold); } else { double lowerOutlierThreshold = mean - (nStdDevForOutlier * stddev); double upperOutlierThreshold = mean + (nStdDevForOutlier * stddev); collectOutliers(values, lowerOutlierThreshold, upperOutlierThreshold); } break; } }
From source file:com.prowidesoftware.swift.model.field.Field94L.java
/** * Set the component3 from a Number object. * <br />//from www .ja v a 2 s . c o m * <em>If the component being set is a fixed length number, the argument will not be * padded.</em> It is recommended for these cases to use the setComponent3(String) * method. * * @see #setComponent3(String) * * @param component3 the Number with the component3 content to set */ public Field94L setComponent3(java.lang.Number component3) { if (component3 != null) { setComponent(3, "" + component3.intValue()); } return this; }
From source file:com.prowidesoftware.swift.model.field.Field95L.java
/** * Set the component3 from a Number object. * <br />/* ww w . ja va 2 s . c om*/ * <em>If the component being set is a fixed length number, the argument will not be * padded.</em> It is recommended for these cases to use the setComponent3(String) * method. * * @see #setComponent3(String) * * @param component3 the Number with the component3 content to set */ public Field95L setComponent3(java.lang.Number component3) { if (component3 != null) { setComponent(3, "" + component3.intValue()); } return this; }