public static double nextAfter(final double start,final double direction){
  if (direction < start) {
    if (start == 0.0) {
      return -Double.MIN_VALUE;
    }
    final long bits=Double.doubleToRawLongBits(start);
    return Double.longBitsToDouble(bits + (bits > 0 ? -1 : 1));
  }
 else   if (direction > start) {
    final long bits=Double.doubleToRawLongBits(start + 0.0f);
    return Double.longBitsToDouble(bits + (bits >= 0 ? 1 : -1));
  }
 else   if (start == direction) {
    return direction;
  }
 else {
    return start + direction;
  }
}

public static double nextAfter ( final double start , final double direction ) { if ( direction < start ) { if ( start == 0.0 ) { return - Double . MIN_VALUE ; } final long bits = Double . doubleToRawLongBits ( start ) ; return Double . longBitsToDouble ( bits + ( bits > 0 ? - 1 : 1 ) ) ; } else if ( direction > start ) { final long bits = Double . doubleToRawLongBits ( start + 0.0f ) ; return Double . longBitsToDouble ( bits + ( bits >= 0 ? 1 : - 1 ) ) ; } else if ( start == direction ) { return direction ; } else { return start + direction ; } }
if both arguments are + - 0 . 0 , direction is returned . if both arguments are + infinity or - infinity , respectively + infinity or - infinity is returned .
