public static double ulp(double d){
  if (Double.isNaN(d)) {
    return Double.NaN;
  }
  if (Double.isInfinite(d)) {
    return Double.POSITIVE_INFINITY;
  }
  if (d == 0.0) {
    return Double.MIN_VALUE;
  }
  d=Math.abs(d);
  if (d == Double.MAX_VALUE) {
    return MAX_ULP;
  }
  return nextAfter(d,Double.MAX_VALUE) - d;
}

public static double ulp ( double d ) { if ( Double . isNaN ( d ) ) { return Double . NaN ; } if ( Double . isInfinite ( d ) ) { return Double . POSITIVE_INFINITY ; } if ( d == 0.0 ) { return Double . MIN_VALUE ; } d = Math . abs ( d ) ; if ( d == Double . MAX_VALUE ) { return MAX_ULP ; } return nextAfter ( d , Double . MAX_VALUE ) - d ; }
returns the size of an ulp ( units in the last place ) of the argument .
