Tabnine Logo
Math.nextAfter
Code IndexAdd Tabnine to your IDE (free)

How to use
nextAfter
method
in
java.lang.Math

Best Java code snippets using java.lang.Math.nextAfter (Showing top 20 results out of 468)

origin: robovm/robovm

/**
 * Returns the next float after {@code start} in the given {@code direction}.
 * @since 1.6
 */
public static float nextAfter(float start, double direction) {
  return Math.nextAfter(start, direction);
}
origin: apache/incubator-druid

 @Override
 protected ExprEval eval(double x, double y)
 {
  return ExprEval.of(Math.nextAfter(x, y));
 }
}
origin: kiegroup/optaplanner

@Override
public Double next() {
  if (to == from) {
    throw new NoSuchElementException();
  }
  double diff = to - from;
  double next = from + diff * workingRandom.nextDouble();
  if (next >= to) {
    // Rounding error occurred
    next = Math.nextAfter(next, Double.NEGATIVE_INFINITY);
  }
  return next;
}
origin: HdrHistogram/HdrHistogram

Math.min(Math.max(Math.nextAfter(percentile, Double.NEGATIVE_INFINITY), 0.0D), 100.0D);
origin: kiegroup/optaplanner

@Test
public void cornerCase() {
  Random random = mock(Random.class);
  NearbyRandom nearbyRandom = new LinearDistributionNearbyRandom(100);
  when(random.nextDouble()).thenReturn(Math.nextAfter(1.0, Double.NEGATIVE_INFINITY));
  assertEquals(9, nearbyRandom.nextInt(random, 10));
  when(random.nextDouble()).thenReturn(Math.nextAfter(1.0, Double.NEGATIVE_INFINITY));
  assertEquals(99, nearbyRandom.nextInt(random, 500));
}
origin: kiegroup/optaplanner

@Test
public void createRandomIterator() {
  Random workingRandom = mock(Random.class);
  when(workingRandom.nextDouble()).thenReturn(0.3, 0.0);
  assertElementsOfIterator(new DoubleValueRange(0.0, 1.0).createRandomIterator(workingRandom), 0.3, 0.0);
  when(workingRandom.nextDouble()).thenReturn(0.3, 0.0);
  assertElementsOfIterator(new DoubleValueRange(100.0, 104.0).createRandomIterator(workingRandom), 101.2, 100.0);
  when(workingRandom.nextDouble()).thenReturn(0.3, 0.0);
  assertElementsOfIterator(new DoubleValueRange(-5.0, 5.0).createRandomIterator(workingRandom), -2.0, -5.0);
  assertAllElementsOfIterator(new DoubleValueRange(7.0, 7.0).createRandomIterator(workingRandom));
  when(workingRandom.nextDouble()).thenReturn(Math.nextAfter(1.0, Double.NEGATIVE_INFINITY));
  assertElementsOfIterator(new DoubleValueRange(0.000001, 0.000002).createRandomIterator(workingRandom),
      Math.nextAfter(0.000002, Double.NEGATIVE_INFINITY));
  when(workingRandom.nextDouble()).thenReturn(Math.nextAfter(1.0, Double.NEGATIVE_INFINITY));
  assertElementsOfIterator(new DoubleValueRange(1000000.0, 2000000.0).createRandomIterator(workingRandom),
      Math.nextAfter(2000000.0, Double.NEGATIVE_INFINITY));
}
origin: kiegroup/optaplanner

@Test
public void cornerCase() {
  Random random = mock(Random.class);
  NearbyRandom nearbyRandom = new ParabolicDistributionNearbyRandom(100);
  when(random.nextDouble()).thenReturn(Math.nextAfter(1.0, Double.NEGATIVE_INFINITY));
  assertEquals(99, nearbyRandom.nextInt(random, 500));
  assertEquals(9, nearbyRandom.nextInt(random, 10));
  when(random.nextDouble()).thenReturn(0.0);
  assertEquals(0, nearbyRandom.nextInt(random, 500));
  assertEquals(0, nearbyRandom.nextInt(random, 10));
}
origin: kiegroup/optaplanner

when(random.nextDouble()).thenReturn(Math.nextAfter(threshold, Double.NEGATIVE_INFINITY));
assertEquals(-1, nearbyRandom.nextInt(random, 1));
origin: shchurov/HorizontalWheelView

private boolean checkEndLock(double radians) {
  if (!endLock) {
    return false;
  }
  boolean hit = false;
  if (radians >= 2 * PI) {
    angle = Math.nextAfter(2 * PI, Double.NEGATIVE_INFINITY);
    hit = true;
  } else if (onlyPositiveValues && radians < 0) {
    angle = 0;
    hit = true;
  } else if (radians <= -2 * PI) {
    angle = Math.nextAfter(-2 * PI, Double.POSITIVE_INFINITY);
    hit = true;
  }
  if (hit) {
    touchHandler.cancelFling();
  }
  return hit;
}
origin: mapsforge/mapsforge

@Test
public void validateLatitudeTest() {
  LatLongUtils.validateLatitude(LatLongUtils.LATITUDE_MAX);
  LatLongUtils.validateLatitude(LatLongUtils.LATITUDE_MIN);
  verifyInvalidLatitude(Double.NaN);
  verifyInvalidLatitude(Math.nextAfter(LatLongUtils.LATITUDE_MAX, Double.POSITIVE_INFINITY));
  verifyInvalidLatitude(Math.nextAfter(LatLongUtils.LATITUDE_MIN, Double.NEGATIVE_INFINITY));
}
origin: mapsforge/mapsforge

@Test
public void validateLongitudeTest() {
  LatLongUtils.validateLongitude(LatLongUtils.LONGITUDE_MAX);
  LatLongUtils.validateLongitude(LatLongUtils.LONGITUDE_MIN);
  verifyInvalidLongitude(Double.NaN);
  verifyInvalidLongitude(Math.nextAfter(LatLongUtils.LONGITUDE_MAX, Double.POSITIVE_INFINITY));
  verifyInvalidLongitude(Math.nextAfter(LatLongUtils.LONGITUDE_MIN, Double.NEGATIVE_INFINITY));
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns the next float after {@code start} in the given {@code direction}.
 * @since 1.6
 */
public static float nextAfter(float start, double direction) {
  return Math.nextAfter(start, direction);
}
origin: MobiVM/robovm

/**
 * Returns the next float after {@code start} in the given {@code direction}.
 * @since 1.6
 */
public static float nextAfter(float start, double direction) {
  return Math.nextAfter(start, direction);
}
origin: stackoverflow.com

 import java.math.BigDecimal;

public class Test
{
 public static void main(String[] args) {
  double maxValue = (double)Long.MAX_VALUE;
  System.out.println(new BigDecimal(maxValue));
  double nextDown = Math.nextAfter(maxValue, 0);
  System.out.println(new BigDecimal(nextDown));
  System.out.println(maxValue-nextDown);
 }
}
origin: com.carrotsearch.randomizedtesting/randomizedtesting-runner

/**
 * Fuzzify the input value by decreasing it by a few ulps, but never past min. 
 */
public static double fuzzDown(Random r, double v, double min) {
 assert v >= min;
 for (int steps = RandomNumbers.randomIntBetween(r, 1, 10); steps > 0 && v > min; steps--) {
  v = Math.nextAfter(v, Double.NEGATIVE_INFINITY);
 }
 return v;
}
origin: com.carrotsearch.randomizedtesting/randomizedtesting-runner

/**
 * Fuzzify the input value by decreasing it by a few ulps, but never past min. 
 */
public static float fuzzDown(Random r, float v, float min) {
 assert v >= min;
 for (int steps = RandomNumbers.randomIntBetween(r, 1, 10); steps > 0 && v > min; steps--) {
  v = Math.nextAfter(v, Double.NEGATIVE_INFINITY);
 }
 return v;
}
origin: org.apache.druid/druid-common

 @Override
 protected ExprEval eval(double x, double y)
 {
  return ExprEval.of(Math.nextAfter(x, y));
 }
}
origin: org.ballerinalang/ballerina-math

  public void execute(Context ctx) {
    double a = ctx.getFloatArgument(0);
    double b = ctx.getFloatArgument(1);
    ctx.setReturnValues(new BFloat(Math.nextAfter(a, b)));
  }
}
origin: dremio/dremio-oss

private Query toRangeQuery(RangeDouble range) {
 return DoublePoint.newRangeQuery(
   range.getField(),
   range.hasMin() ?
    range.getMinInclusive() ? range.getMin()
    : Math.nextUp(range.getMin())
   : Double.NEGATIVE_INFINITY,
   range.hasMax() ?
    range.getMaxInclusive() ? range.getMax()
    : Math.nextAfter(range.getMax(), -Double.MAX_VALUE)
   : Double.POSITIVE_INFINITY );
}
origin: dremio/dremio-oss

private Query toRangeQuery(RangeFloat range) {
 return FloatPoint.newRangeQuery(
   range.getField(),
   range.hasMin() ?
    range.getMinInclusive() ? range.getMin()
    : Math.nextUp(range.getMin())
   : Float.NEGATIVE_INFINITY,
   range.hasMax() ?
    range.getMaxInclusive() ? range.getMax()
    : Math.nextAfter(range.getMax(), -Double.MAX_VALUE)
   : Float.POSITIVE_INFINITY );
}
java.langMathnextAfter

Javadoc

Returns the next double after start in the given direction.

Popular methods of Math

  • min
    Returns the smaller of two long values. That is, the result is the argument closer to the value of L
  • max
    Returns the greater of two long values. That is, the result is the argument closer to the value of L
  • abs
    Returns the absolute value of a long value. If the argument is not negative, the argument is returne
  • round
    Returns the closest int to the argument, with ties rounding up. Special cases: * If the argument is
  • pow
    Returns the value of the first argument raised to the power of the second argument. Special cases: *
  • sqrt
    Returns the correctly rounded positive square root of a double value. Special cases: * If the argume
  • ceil
    Returns the smallest (closest to negative infinity) double value that is greater than or equal to th
  • floor
    Returns the largest (closest to positive infinity) double value that is less than or equal to the ar
  • random
    Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0. Returne
  • sin
    Returns the trigonometric sine of an angle. Special cases: * If the argument is NaN or an infinit
  • cos
    Returns the trigonometric cosine of an angle. Special cases: * If the argument is NaN or an infin
  • log
    Returns the natural logarithm (base e) of a doublevalue. Special cases: * If the argument is NaN
  • cos,
  • log,
  • exp,
  • toRadians,
  • atan2,
  • log10,
  • acos,
  • tan,
  • toDegrees,
  • atan

Popular in Java

  • Start an intent from android
  • scheduleAtFixedRate (Timer)
  • setScale (BigDecimal)
  • notifyDataSetChanged (ArrayAdapter)
  • HttpServer (com.sun.net.httpserver)
    This class implements a simple HTTP server. A HttpServer is bound to an IP address and port number a
  • FileReader (java.io)
    A specialized Reader that reads from a file in the file system. All read requests made by calling me
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • JLabel (javax.swing)
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now