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

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

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

Double.longValue介绍

[英]Returns the value of this Double as a long (by casting to type long).
[中]以long形式返回此Double的值(通过强制转换为long类型)。

代码示例

代码示例来源:origin: aws/aws-sdk-java

private Long convertToLongIfNotNull(Double number) {
  if (number == null) {
    return null;
  }
  return number.longValue();
}

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

public Long toLong(Double self) {
  return self.longValue();
}

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

void add(EffortSum other) {
  Double otherValue = other.newEffort;
  if (otherValue != null) {
   add(otherValue.longValue());
  }
 }
}

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

/**
 * The value of this measure as a long if the type is {@link Measure.ValueType#LONG}.
 *
 * @throws IllegalStateException if the value type of the measure is not {@link Measure.ValueType#LONG}
 */
public long getLongValue() {
 checkValueType(ValueType.LONG);
 return value.longValue();
}

代码示例来源:origin: aws/aws-sdk-java

@Deprecated
public final long getElapsedTimeMillis() {
  Double v = getTimeTakenMillisIfKnown();
  return v == null ? UNKNOWN : v.longValue();
}

代码示例来源:origin: pentaho/pentaho-kettle

protected Timestamp convertNumberToTimestamp( Double d ) {
 if ( d == null ) {
  return null;
 }
 long nanos = d.longValue();
 return convertIntegerToTimestamp( nanos );
}

代码示例来源:origin: pentaho/pentaho-kettle

protected InetAddress convertNumberToInternetAddress( Double d ) throws KettleValueException {
 if ( d == null ) {
  return null;
 }
 long nanos = d.longValue();
 return convertIntegerToInternetAddress( nanos );
}

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

public long evaluate(String xml, String path) {
  return xpath.evalNumber(xml, path).longValue();
 }
}

代码示例来源:origin: apache/incubator-pinot

@Override
public long getLongValue(int dictId) {
 return ((Double) get(dictId)).longValue();
}

代码示例来源:origin: apache/incubator-druid

public static Function<Number, DateTime> createNumericTimestampParser(
  final String format
)
{
 if ("posix".equalsIgnoreCase(format)) {
  return input -> DateTimes.utc(TimeUnit.SECONDS.toMillis(input.longValue()));
 } else if ("micro".equalsIgnoreCase(format)) {
  return input -> DateTimes.utc(TimeUnit.MICROSECONDS.toMillis(input.longValue()));
 } else if ("nano".equalsIgnoreCase(format)) {
  return input -> DateTimes.utc(TimeUnit.NANOSECONDS.toMillis(input.longValue()));
 } else if ("ruby".equalsIgnoreCase(format)) {
  return input -> DateTimes.utc(Double.valueOf(input.doubleValue() * 1000).longValue());
 } else {
  return input -> DateTimes.utc(input.longValue());
 }
}

代码示例来源:origin: twosigma/beakerx

@Override
 public void run() {
  if (jarNumbers > 0) {
   String info = getInfo(currentLine);
   String sizeWithUnit = byteCountToDisplaySize(new Double(sizeInKb * 1000).longValue());
   String status = String.format("%d jar%s, %s downloaded at %s %s", jarNumbers, getPluralFormWhenNumberOfJarGreaterThanOne(), sizeWithUnit, speed, info);
   widget.setValue(status + "</br>" + formatCurrentLine());
   widget.setDomClasses(asList("text-ellipsis"));
  }
 }
}, 0, PERIOD);

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

private static Optional<Measure> toLongMeasure(LiveMeasureDto measureDto, @Nullable Double value, @Nullable String data) {
 if (value == null) {
  return toNoValueMeasure(measureDto);
 }
 return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.longValue(), data));
}

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

protected long limitInMb() {
  ServerConfig serverConfig = goConfigService.serverConfig();
  return serverConfig.isArtifactPurgingAllowed() ? new Double(serverConfig.getPurgeStart() * GoConstants.MEGABYTES_IN_GIGABYTE).longValue() : Integer.MAX_VALUE;
}

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

private static Optional<Measure> toLongMeasure(MeasureDto measureDto, @Nullable Double value, String data) {
 if (value == null) {
  return toNoValueMeasure(measureDto);
 }
 return of(setCommonProperties(Measure.newMeasureBuilder(), measureDto).create(value.longValue(), data));
}

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

private void addEffortToMaintainabilityRatingAMeasure(Component component, Path<Counter> path) {
 long developmentCostValue = path.current().devCosts;
 Optional<Measure> effortMeasure = measureRepository.getRawMeasure(component, maintainabilityRemediationEffortMetric);
 long effort = effortMeasure.isPresent() ? effortMeasure.get().getLongValue() : 0L;
 long upperGradeCost = ((Double) (ratingSettings.getDebtRatingGrid().getGradeLowerBound(Rating.B) * developmentCostValue)).longValue();
 long effortToRatingA = upperGradeCost < effort ? (effort - upperGradeCost) : 0L;
 measureRepository.add(component, effortToMaintainabilityRatingAMetric, Measure.newMeasureBuilder().create(effortToRatingA));
}

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

@Test
public void canDoubleToLong() {
  Double value = 11204.0345612345D;
  when(item.getValue()).thenReturn(value);
  when(item.getType()).thenReturn("D");
  when(instruction.getOpcode()).thenReturn(Opcode.DOUBLE_TO_LONG);
  op = (UnaryMathOp) opFactory.create(location, addressToLocation, vm);
  op.execute(node, mState);
  verify(mState, times(1)).assignRegister(eq(REGISTER_A), eq(new HeapItem(value.longValue(), "J")));
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testDoubleLastCombiningBufferAggregator()
{
 BufferAggregator agg = combiningAggFactory.factorizeBuffered(
   colSelectorFactory);
 ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleLastAggFactory.getMaxIntermediateSizeWithNulls()]);
 agg.init(buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
 Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2];
 Assert.assertEquals(expected.lhs, result.lhs);
 Assert.assertEquals(expected.rhs, result.rhs, 0.0001);
 Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0));
 Assert.assertEquals(expected.rhs, agg.getDouble(buffer, 0), 0.0001);
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testDoubleFirstCombiningBufferAggregator()
{
 BufferAggregator agg = combiningAggFactory.factorizeBuffered(
   colSelectorFactory);
 ByteBuffer buffer = ByteBuffer.wrap(new byte[doubleFirstAggFactory.getMaxIntermediateSizeWithNulls()]);
 agg.init(buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 aggregate(agg, buffer, 0);
 Pair<Long, Double> result = (Pair<Long, Double>) agg.get(buffer, 0);
 Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2];
 Assert.assertEquals(expected.lhs, result.lhs);
 Assert.assertEquals(expected.rhs, result.rhs, 0.0001);
 Assert.assertEquals(expected.rhs.longValue(), agg.getLong(buffer, 0));
 Assert.assertEquals(expected.rhs, agg.getDouble(buffer, 0), 0.0001);
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testDoubleFirstCombiningAggregator()
{
 Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
 aggregate(agg);
 aggregate(agg);
 aggregate(agg);
 aggregate(agg);
 Pair<Long, Double> result = (Pair<Long, Double>) agg.get();
 Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2];
 Assert.assertEquals(expected.lhs, result.lhs);
 Assert.assertEquals(expected.rhs, result.rhs, 0.0001);
 Assert.assertEquals(expected.rhs.longValue(), agg.getLong());
 Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001);
}

代码示例来源:origin: apache/incubator-druid

@Test
public void testDoubleLastCombiningAggregator()
{
 Aggregator agg = combiningAggFactory.factorize(colSelectorFactory);
 aggregate(agg);
 aggregate(agg);
 aggregate(agg);
 aggregate(agg);
 Pair<Long, Double> result = (Pair<Long, Double>) agg.get();
 Pair<Long, Double> expected = (Pair<Long, Double>) pairs[2];
 Assert.assertEquals(expected.lhs, result.lhs);
 Assert.assertEquals(expected.rhs, result.rhs, 0.0001);
 Assert.assertEquals(expected.rhs.longValue(), agg.getLong());
 Assert.assertEquals(expected.rhs, agg.getDouble(), 0.0001);
}

相关文章