Double d = 5.25; Integer i = d.intValue(); // i becomes 5
/** * Set up the max deep of decision tree. * @param maxDeep The parameter value. * @return Trainer with new maxDeep parameter value. */ public DecisionTreeClassificationTrainer withMaxDeep(Double maxDeep){ this.maxDeep = maxDeep.intValue(); return this; }
private boolean naturalOrderIsNotAnInteger() { return naturalOrder - new Double(naturalOrder).intValue() > 0; } }
public static boolean isBisect(double naturalOrder) { return naturalOrder - new Double(naturalOrder).intValue() > 0;//TODO: may be we should be using long, as int can lead to truncation }
Double d = new Double(1.23); int i = d.intValue();
private static List<Map.Entry<String, Integer>> doubleToInteger(List<Map.Entry<String, Double>> list) { List<Map.Entry<String, Integer>> result = new ArrayList<Map.Entry<String, Integer>>(list.size()); for (Map.Entry<String, Double> entry : list) { result.add(new AbstractMap.SimpleEntry<String, Integer>(entry.getKey(), entry.getValue().intValue())); } return result; } }
@Override public Serializable[][] getParameterValues() { double maxElemCount = (maxVal - minVal) + 1; int numBatches = new Double(Math.ceil(maxElemCount / fetchSize)).intValue(); Serializable[][] parameters = new Serializable[numBatches][2]; int batchIndex = 0; for (long start = minVal; start <= maxVal; start += fetchSize, batchIndex++) { long end = start + fetchSize - 1; if (end > maxVal) { end = maxVal; } parameters[batchIndex] = new Long[]{start, end}; } return parameters; }
public static int evaluatePolynomialAt(int n, int a, int x) { int result = a; for (int i = 1; i <= n; i++) { result = result + Double.valueOf(a * Math.pow(x, i)).intValue(); } return result; }
private int getScale(){ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); int width = display.getWidth(); Double val = new Double(width)/new Double(PIC_WIDTH); val = val * 100d; return val.intValue(); }
private int fragmentedCpu() { Double res = nodeIdToResources.get().values().parallelStream().filter(this::isFragmented) .mapToDouble(SupervisorResources::getAvailableCpu).filter(x -> x > 0).sum(); return res.intValue(); }
private double fragmentedMemory() { Double res = nodeIdToResources.get().values().parallelStream().filter(this::isFragmented) .mapToDouble(SupervisorResources::getAvailableMem).filter(x -> x > 0).sum(); return res.intValue(); }
/** * The value of this measure as a int if the type is {@link Measure.ValueType#INT}. * * @throws IllegalStateException if the value type of the measure is not {@link Measure.ValueType#INT} */ public int getIntValue() { checkValueType(ValueType.INT); return value.intValue(); }
/** * The value of this measure as a boolean if the type is {@link Measure.ValueType#BOOLEAN}. * * @throws IllegalStateException if the value type of the measure is not {@link Measure.ValueType#BOOLEAN} */ public boolean getBooleanValue() { checkValueType(ValueType.BOOLEAN); return value != null && value.intValue() == 1; }
/** * @return Value of preudorandom discrete variable. */ public int getInt() { return get().intValue(); }
private static Optional<Measure> toIntegerMeasure(LiveMeasureDto measureDto, @Nullable Double value, @Nullable String data) { if (value == null) { return toNoValueMeasure(measureDto); } return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.intValue(), data)); }
@Override public void run() { // Poll as fast as possible to reproduce ConcurrentModificationException while (!doStop.get()) { try { int size = ((Double) metric.metricValue()).intValue(); observedSize.set(size); } catch (Exception e) { exceptionHolder.set(e); return; } } } };
private static Optional<Measure> toIntegerMeasure(MeasureDto measureDto, @Nullable Double value, String data) { if (value == null) { return toNoValueMeasure(measureDto); } return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.intValue(), data)); }
private String generateRating(MetricDto metric, LiveMeasureDto measure) { Rating rating = valueOf(getNonNullValue(measure, LiveMeasureDto::getValue).intValue()); return generateBadge(metric, rating.name(), COLOR_BY_RATING.get(rating)); }
@Test public void canDoubleToInt() { Double value = 11204.0345612345D; when(item.getValue()).thenReturn(value); when(item.getType()).thenReturn("D"); when(instruction.getOpcode()).thenReturn(Opcode.DOUBLE_TO_INT); op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm); op.execute(node, mState); verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.intValue(), "I"))); }
@Override public void close() throws Exception { // Test counter used in open and close only this.openCloseCounter.add(0.5); Assert.assertEquals(1, this.openCloseCounter.getLocalValue().intValue()); } }