code: public static double ulp(double x) {
          if (Double.isInfinite(x)) {
              return Double.POSITIVE_INFINITY;
          }
          return abs(x - Double.longBitsToDouble(Double.doubleToLongBits(x) ^ 1));
      }
docs: Compute least significant bit (Unit in Last Position) for a number.
  @param x number from which ulp is requested
  @return ulp(x)