java.lang.Math.nextUp()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(156)

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

Math.nextUp介绍

[英]Returns the next double larger than d.
[中]返回下一个大于d的双精度值。

代码示例

代码示例来源:origin: google/guava

static double nextDown(double d) {
 return -Math.nextUp(-d);
}

代码示例来源:origin: prestodb/presto

static double nextDown(double d) {
 return -Math.nextUp(-d);
}

代码示例来源:origin: google/j2objc

static double nextDown(double d) {
 return -Math.nextUp(-d);
}

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

/**
 * Returns the next float larger than {@code f}.
 * @since 1.6
 */
public static float nextUp(float f) {
  return Math.nextUp(f);
}

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

/**
 * Returns the next double larger than {@code d}.
 * @since 1.6
 */
public static double nextUp(double d) {
  return Math.nextUp(d);
}

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

static double nextDown(double d) {
 return -Math.nextUp(-d);
}

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

@Override
 protected ExprEval eval(double param)
 {
  return ExprEval.of(Math.nextUp(param));
 }
}

代码示例来源:origin: google/error-prone

@Override
Float nextNumber(Number actual) {
 float number = actual.floatValue();
 return Math.min(Math.nextUp(number) - number, number - Math.nextDown(number));
}

代码示例来源:origin: google/error-prone

@Override
Double nextNumber(Number actual) {
 double number = actual.doubleValue();
 return Math.min(Math.nextUp(number) - number, number - Math.nextDown(number));
}

代码示例来源:origin: vavr-io/vavr

@GwtIncompatible("Math::nextUp is not implemented")
  static BigDecimal asDecimal(double number) {
    if (number == NEGATIVE_INFINITY) {
      final BigDecimal result = BigDecimal.valueOf(Math.nextUp(NEGATIVE_INFINITY));
      return result.subtract(INFINITY_DISTANCE.get());
    } else if (number == POSITIVE_INFINITY) {
      final BigDecimal result = BigDecimal.valueOf(Math.nextDown(POSITIVE_INFINITY));
      return result.add(INFINITY_DISTANCE.get());
    } else {
      return BigDecimal.valueOf(number);
    }
  }
}

代码示例来源:origin: alibaba/Sentinel

double warmingQps = Math.nextUp(1.0 / (aboveToken * slope + 1.0 / count));
  costTime = Math.round(1.0 * (acquireCount) / warmingQps * 1000);
} else {

代码示例来源:origin: alibaba/Sentinel

@Override
public boolean canPass(Node node, int acquireCount, boolean prioritized) {
  long passQps = node.passQps();
  long previousQps = node.previousPassQps();
  syncToken(previousQps);
  // 开始计算它的斜率
  // 如果进入了警戒线,开始调整他的qps
  long restToken = storedTokens.get();
  if (restToken >= warningToken) {
    long aboveToken = restToken - warningToken;
    // 消耗的速度要比warning快,但是要比慢
    // current interval = restToken*slope+1/count
    double warningQps = Math.nextUp(1.0 / (aboveToken * slope + 1.0 / count));
    if (passQps + acquireCount <= warningQps) {
      return true;
    }
  } else {
    if (passQps + acquireCount <= count) {
      return true;
    }
  }
  return false;
}

代码示例来源:origin: vavr-io/vavr

@GwtIncompatible
static Iterator<Double> rangeClosedBy(double from, double toInclusive, double step) {
  if (from == toInclusive) {
    return of(from);
  }
  final double toExclusive = (step > 0) ? Math.nextUp(toInclusive) : Math.nextDown(toInclusive);
  return rangeBy(from, toExclusive, step);
}

代码示例来源:origin: prestodb/presto

@OutputFunction(StandardTypes.VARCHAR)
  public static void output(SpatialPartitioningState state, BlockBuilder out)
  {
    if (state.getCount() == 0) {
      out.appendNull();
      return;
    }

    List<Rectangle> samples = state.getSamples();

    int partitionCount = state.getPartitionCount();
    int maxItemsPerNode = (samples.size() + partitionCount - 1) / partitionCount;
    Rectangle envelope = state.getExtent();

    // Add a small buffer on the right and upper sides
    Rectangle paddedExtent = new Rectangle(envelope.getXMin(), envelope.getYMin(), Math.nextUp(envelope.getXMax()), Math.nextUp(envelope.getYMax()));

    VARCHAR.writeString(out, KdbTreeUtils.toJson(buildKdbTree(maxItemsPerNode, paddedExtent, samples)));
  }
}

代码示例来源:origin: prestodb/presto

@Test(dataProvider = "partitionCount")
public void test(int partitionCount)
{
  InternalAggregationFunction function = getFunction();
  List<OGCGeometry> geometries = makeGeometries();
  Block geometryBlock = makeGeometryBlock(geometries);
  Block partitionCountBlock = BlockAssertions.createRLEBlock(partitionCount, geometries.size());
  Rectangle expectedExtent = new Rectangle(-10, -10, Math.nextUp(10.0), Math.nextUp(10.0));
  String expectedValue = getSpatialPartitioning(expectedExtent, geometries, partitionCount);
  AccumulatorFactory accumulatorFactory = function.bind(Ints.asList(0, 1, 2), Optional.empty());
  Page page = new Page(geometryBlock, partitionCountBlock);
  Accumulator accumulator = accumulatorFactory.createAccumulator();
  accumulator.addInput(page);
  String aggregation = (String) BlockAssertions.getOnlyValue(accumulator.getFinalType(), getFinalBlock(accumulator));
  assertEquals(aggregation, expectedValue);
  GroupedAccumulator groupedAggregation = accumulatorFactory.createGroupedAccumulator();
  groupedAggregation.addInput(createGroupByIdBlock(0, page.getPositionCount()), page);
  String groupValue = (String) getGroupValue(groupedAggregation, 0);
  assertEquals(groupValue, expectedValue);
}

代码示例来源:origin: prestodb/presto

@Test
public void testCastToBigint()
{
  assertFunction("cast(37.7E0 as bigint)", BIGINT, 38L);
  assertFunction("cast(-37.7E0 as bigint)", BIGINT, -38L);
  assertFunction("cast(17.1E0 as bigint)", BIGINT, 17L);
  assertFunction("cast(-17.1E0 as bigint)", BIGINT, -17L);
  assertFunction("cast(9.2E18 as bigint)", BIGINT, 9200000000000000000L);
  assertFunction("cast(-9.2E18 as bigint)", BIGINT, -9200000000000000000L);
  assertFunction("cast(2.21E9 as bigint)", BIGINT, 2210000000L);
  assertFunction("cast(-2.21E9 as bigint)", BIGINT, -2210000000L);
  assertFunction("cast(17.5E0 as bigint)", BIGINT, 18L);
  assertFunction("cast(-17.5E0 as bigint)", BIGINT, -18L);
  assertFunction("cast(" + Math.nextDown(0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextDown(0x1.0p63));
  assertInvalidFunction("cast(" + 0x1.0p63 + " as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(" + Math.nextUp(0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(" + Math.nextDown(-0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  assertFunction("cast(" + -0x1.0p63 + " as bigint)", BIGINT, (long) -0x1.0p63);
  assertFunction("cast(" + Math.nextUp(-0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextUp(-0x1.0p63));
  assertInvalidFunction("cast(9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(-9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(infinity() as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(-infinity() as bigint)", INVALID_CAST_ARGUMENT);
  assertInvalidFunction("cast(nan() as bigint)", INVALID_CAST_ARGUMENT);
}

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public Query withinQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return FloatRange.newWithinQuery(field,
    new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
    new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
}
@Override

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
  public Query intersectsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
    return FloatRange.newIntersectsQuery(field,
      new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
      new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
  }
},

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public Query containsQuery(String field, Object from, Object to, boolean includeFrom, boolean includeTo) {
  return FloatRange.newContainsQuery(field,
    new float[] {includeFrom ? (Float)from : Math.nextUp((Float)from)},
    new float[] {includeTo ? (Float)to : Math.nextDown((Float)to)});
}
@Override

代码示例来源:origin: rnewson/couchdb-lucene

@Override
public Query toRangeQuery(final String name, final String lower, final String upper,
             final boolean lowerInclusive, final boolean upperInclusive) {
  return FloatPoint.newRangeQuery(name,
                  lowerInclusive ? toFloat(lower) : Math.nextUp(toFloat(lower)),
                  upperInclusive ? toFloat(upper) : Math.nextDown(toFloat(upper)));
}

相关文章