java.lang.Double.intValue()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(5.3k)|赞(0)|评价(0)|浏览(213)

本文整理了Java中java.lang.Double.intValue()方法的一些代码示例,展示了Double.intValue()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.intValue()方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:intValue

Double.intValue介绍

[英]Returns the value of this Double as an int (by casting to type int).
[中]将此Double的值作为int返回(通过强制转换为int类型)。

代码示例

代码示例来源:origin: stackoverflow.com

Double d = 5.25;
Integer i = d.intValue(); // i becomes 5

代码示例来源:origin: apache/ignite

/**
 * 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;
}

代码示例来源:origin: gocd/gocd

private boolean naturalOrderIsNotAnInteger() {
    return naturalOrder - new Double(naturalOrder).intValue() > 0;
  }
}

代码示例来源:origin: gocd/gocd

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
}

代码示例来源:origin: stackoverflow.com

Double d = new Double(1.23);
int i = d.intValue();

代码示例来源:origin: hankcs/HanLP

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;
  }
}

代码示例来源:origin: apache/flink

@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;
}

代码示例来源:origin: shekhargulati/99-problems

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;
}

代码示例来源:origin: stackoverflow.com

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();
}

代码示例来源:origin: apache/storm

private int fragmentedCpu() {
  Double res = nodeIdToResources.get().values().parallelStream().filter(this::isFragmented)
                 .mapToDouble(SupervisorResources::getAvailableCpu).filter(x -> x > 0).sum();
  return res.intValue();
}

代码示例来源:origin: apache/storm

private double fragmentedMemory() {
  Double res = nodeIdToResources.get().values().parallelStream().filter(this::isFragmented)
                 .mapToDouble(SupervisorResources::getAvailableMem).filter(x -> x > 0).sum();
  return res.intValue();
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * 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();
}

代码示例来源:origin: SonarSource/sonarqube

/**
 * 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;
}

代码示例来源:origin: apache/ignite

/**
 * @return Value of preudorandom discrete variable.
 */
public int getInt() {
  return get().intValue();
}

代码示例来源:origin: SonarSource/sonarqube

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));
}

代码示例来源:origin: apache/kafka

@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;
      }
    }
  }
};

代码示例来源:origin: SonarSource/sonarqube

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));
}

代码示例来源:origin: SonarSource/sonarqube

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));
}

代码示例来源:origin: CalebFenton/simplify

@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")));
}

代码示例来源:origin: apache/flink

@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());
  }
}

相关文章