public static double nextAfter(final double start,final double direction){
  if (Double.isNaN(start) || Double.isNaN(direction)) {
    return Double.NaN;
  }
  if (start == direction) {
    return direction;
  }
  final double absStart=Math.abs(start);
  final double absDir=Math.abs(direction);
  final boolean toZero=!isSameSign(start,direction) || absDir < absStart;
  if (toZero) {
    if (absStart == Double.MIN_VALUE) {
      return copySign(0.0,start);
    }
    if (Double.isInfinite(absStart)) {
      return copySign(Double.MAX_VALUE,start);
    }
    return copySign(Double.longBitsToDouble(Double.doubleToLongBits(absStart) - 1L),start);
  }
 else {
    if (start == 0.0) {
      return copySign(Double.MIN_VALUE,direction);
    }
    if (absStart == Double.MAX_VALUE) {
      return copySign(Double.POSITIVE_INFINITY,start);
    }
    return copySign(Double.longBitsToDouble(Double.doubleToLongBits(absStart) + 1L),start);
  }
}

public static double nextAfter ( final double start , final double direction ) { if ( Double . isNaN ( start ) || Double . isNaN ( direction ) ) { return Double . NaN ; } if ( start == direction ) { return direction ; } final double absStart = Math . abs ( start ) ; final double absDir = Math . abs ( direction ) ; final boolean toZero = ! isSameSign ( start , direction ) || absDir < absStart ; if ( toZero ) { if ( absStart == Double . MIN_VALUE ) { return copySign ( 0.0 , start ) ; } if ( Double . isInfinite ( absStart ) ) { return copySign ( Double . MAX_VALUE , start ) ; } return copySign ( Double . longBitsToDouble ( Double . doubleToLongBits ( absStart ) - 1L ) , start ) ; } else { if ( start == 0.0 ) { return copySign ( Double . MIN_VALUE , direction ) ; } if ( absStart == Double . MAX_VALUE ) { return copySign ( Double . POSITIVE_INFINITY , start ) ; } return copySign ( Double . longBitsToDouble ( Double . doubleToLongBits ( absStart ) + 1L ) , start ) ; } }
returns the next representable floating point number after the first argument in the direction of the second argument .
