code: private static double ulp(double dval, boolean subtracting)
  	{
  		long lbits = Double.doubleToLongBits(dval) & ~signMask;
  		int binexp = (int) (lbits >>> expShift);
  		double ulpval;
  		if (subtracting && (binexp >= expShift) && ((lbits & fractMask) == 0L))
  		{
  			// for subtraction from normalized, powers of 2,
  			// use next-smaller exponent
  			binexp -= 1;
  		}
  		if (binexp > expShift)
  		{
  			ulpval = Double.longBitsToDouble(((long) (binexp - expShift)) << expShift);
  		}
  		else if (binexp == 0)
  		{
  			ulpval = Double.MIN_VALUE;
  		}
  		else
  		{
  			ulpval = Double.longBitsToDouble(1L << (binexp - 1));
  		}
  		if (subtracting)
  			ulpval = -ulpval;
  
  		return ulpval;
  	}
docs: /*
  Compute a number that is the ULP of the given value,
  for purposes of addition/subtraction. Generally easy.
  More difficult if subtracting and the argument
  is a normalized a power of 2, as the ULP changes at these points.