code: public static double nextUp(double d) {
          if (Double.isNaN(d) || d == Double.POSITIVE_INFINITY) {
              return d;
          } else {
              d += 0.0;
              return Double.longBitsToDouble(Double.doubleToRawLongBits(d) + ((d >= 0.0) ? +1 : -1));
          }
      }
docs: Returns next bigger double value considering precision of the argument.