Next value

ReturnMethodSummary
static doublenextAfter(double start, double direction)Returns the floating-point number adjacent to the first argument in the direction of the second argument.
static floatnextAfter(float start, double direction)Returns the floating-point number adjacent to the first argument in the direction of the second argument.
static doublenextUp(double d)Returns the floating-point value adjacent to d in the direction of positive infinity.
static floatnextUp(float f)Returns the floating-point value adjacent to f in the direction of positive infinity.

public class Main {
  public static void main(String[] args) {

    System.out.println(Math.nextAfter(2,1.2));
    System.out.println(Math.nextUp(1.2));
  }
}

The output:


1.9999999
1.2000000000000002
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.