public static double ulp(final double value){
  if (USE_JDK_MATH) {
    return Math.ulp(value);
  }
  final int exponent=getExponent(value);
  if (exponent >= MIN_DOUBLE_NORMAL_EXPONENT + 52) {
    if (exponent == MAX_DOUBLE_EXPONENT + 1) {
      return Math.abs(value);
    }
    return Double.longBitsToDouble(exponent + (MAX_DOUBLE_EXPONENT - 52L) << 52);
  }
 else {
    if (exponent == MIN_DOUBLE_NORMAL_EXPONENT - 1) {
      return Double.MIN_VALUE;
    }
    return Double.longBitsToDouble(1L << exponent - MIN_DOUBLE_NORMAL_EXPONENT);
  }
}

public static double ulp ( final double value ) { if ( USE_JDK_MATH ) { return Math . ulp ( value ) ; } final int exponent = getExponent ( value ) ; if ( exponent >= MIN_DOUBLE_NORMAL_EXPONENT + 52 ) { if ( exponent == MAX_DOUBLE_EXPONENT + 1 ) { return Math . abs ( value ) ; } return Double . longBitsToDouble ( exponent + ( MAX_DOUBLE_EXPONENT - 52L ) << 52 ) ; } else { if ( exponent == MIN_DOUBLE_NORMAL_EXPONENT - 1 ) { return Double . MIN_VALUE ; } return Double . longBitsToDouble ( 1L << exponent - MIN_DOUBLE_NORMAL_EXPONENT ) ; } }
the ulp ( unit in the last place ) is the distance to the next value larger in magnitude .
