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

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

本文整理了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

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

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

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

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

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

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

  1. /**
  2. * Returns the next float larger than {@code f}.
  3. * @since 1.6
  4. */
  5. public static float nextUp(float f) {
  6. return Math.nextUp(f);
  7. }

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

  1. /**
  2. * Returns the next double larger than {@code d}.
  3. * @since 1.6
  4. */
  5. public static double nextUp(double d) {
  6. return Math.nextUp(d);
  7. }

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

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

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

  1. @Override
  2. protected ExprEval eval(double param)
  3. {
  4. return ExprEval.of(Math.nextUp(param));
  5. }
  6. }

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

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

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

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

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

  1. @GwtIncompatible("Math::nextUp is not implemented")
  2. static BigDecimal asDecimal(double number) {
  3. if (number == NEGATIVE_INFINITY) {
  4. final BigDecimal result = BigDecimal.valueOf(Math.nextUp(NEGATIVE_INFINITY));
  5. return result.subtract(INFINITY_DISTANCE.get());
  6. } else if (number == POSITIVE_INFINITY) {
  7. final BigDecimal result = BigDecimal.valueOf(Math.nextDown(POSITIVE_INFINITY));
  8. return result.add(INFINITY_DISTANCE.get());
  9. } else {
  10. return BigDecimal.valueOf(number);
  11. }
  12. }
  13. }

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

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

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

  1. @Override
  2. public boolean canPass(Node node, int acquireCount, boolean prioritized) {
  3. long passQps = node.passQps();
  4. long previousQps = node.previousPassQps();
  5. syncToken(previousQps);
  6. // 开始计算它的斜率
  7. // 如果进入了警戒线,开始调整他的qps
  8. long restToken = storedTokens.get();
  9. if (restToken >= warningToken) {
  10. long aboveToken = restToken - warningToken;
  11. // 消耗的速度要比warning快,但是要比慢
  12. // current interval = restToken*slope+1/count
  13. double warningQps = Math.nextUp(1.0 / (aboveToken * slope + 1.0 / count));
  14. if (passQps + acquireCount <= warningQps) {
  15. return true;
  16. }
  17. } else {
  18. if (passQps + acquireCount <= count) {
  19. return true;
  20. }
  21. }
  22. return false;
  23. }

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

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

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

  1. @OutputFunction(StandardTypes.VARCHAR)
  2. public static void output(SpatialPartitioningState state, BlockBuilder out)
  3. {
  4. if (state.getCount() == 0) {
  5. out.appendNull();
  6. return;
  7. }
  8. List<Rectangle> samples = state.getSamples();
  9. int partitionCount = state.getPartitionCount();
  10. int maxItemsPerNode = (samples.size() + partitionCount - 1) / partitionCount;
  11. Rectangle envelope = state.getExtent();
  12. // Add a small buffer on the right and upper sides
  13. Rectangle paddedExtent = new Rectangle(envelope.getXMin(), envelope.getYMin(), Math.nextUp(envelope.getXMax()), Math.nextUp(envelope.getYMax()));
  14. VARCHAR.writeString(out, KdbTreeUtils.toJson(buildKdbTree(maxItemsPerNode, paddedExtent, samples)));
  15. }
  16. }

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

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

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

  1. @Test
  2. public void testCastToBigint()
  3. {
  4. assertFunction("cast(37.7E0 as bigint)", BIGINT, 38L);
  5. assertFunction("cast(-37.7E0 as bigint)", BIGINT, -38L);
  6. assertFunction("cast(17.1E0 as bigint)", BIGINT, 17L);
  7. assertFunction("cast(-17.1E0 as bigint)", BIGINT, -17L);
  8. assertFunction("cast(9.2E18 as bigint)", BIGINT, 9200000000000000000L);
  9. assertFunction("cast(-9.2E18 as bigint)", BIGINT, -9200000000000000000L);
  10. assertFunction("cast(2.21E9 as bigint)", BIGINT, 2210000000L);
  11. assertFunction("cast(-2.21E9 as bigint)", BIGINT, -2210000000L);
  12. assertFunction("cast(17.5E0 as bigint)", BIGINT, 18L);
  13. assertFunction("cast(-17.5E0 as bigint)", BIGINT, -18L);
  14. assertFunction("cast(" + Math.nextDown(0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextDown(0x1.0p63));
  15. assertInvalidFunction("cast(" + 0x1.0p63 + " as bigint)", INVALID_CAST_ARGUMENT);
  16. assertInvalidFunction("cast(" + Math.nextUp(0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  17. assertInvalidFunction("cast(" + Math.nextDown(-0x1.0p63) + " as bigint)", INVALID_CAST_ARGUMENT);
  18. assertFunction("cast(" + -0x1.0p63 + " as bigint)", BIGINT, (long) -0x1.0p63);
  19. assertFunction("cast(" + Math.nextUp(-0x1.0p63) + " as bigint)", BIGINT, (long) Math.nextUp(-0x1.0p63));
  20. assertInvalidFunction("cast(9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  21. assertInvalidFunction("cast(-9.3E18 as bigint)", INVALID_CAST_ARGUMENT);
  22. assertInvalidFunction("cast(infinity() as bigint)", INVALID_CAST_ARGUMENT);
  23. assertInvalidFunction("cast(-infinity() as bigint)", INVALID_CAST_ARGUMENT);
  24. assertInvalidFunction("cast(nan() as bigint)", INVALID_CAST_ARGUMENT);
  25. }

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

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

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

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

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

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

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

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

相关文章