LongRangeSet (LongRangeSet shiftSize, LongRangeType lrType, boolean unsigned) { if (isEmpty() || shiftSize.isEmpty()) return empty(); int maxShift = lrType.bits() - 1; if (shiftSize.min() < 0 || shiftSize.max() > maxShift) { shiftSize = shiftSize.bitwiseAnd(point(maxShift)); } long min = shiftSize.min(); long max = shiftSize.max(); LongRangeSet negative = meet(range(lrType.min(), -1)); LongRangeSet positive = meet(range(0, lrType.max())); LongRangeSet positiveResult = positive.shrPositive(min, max, lrType); LongRangeSet negativeResult; LongRangeSet negativeComplement = point(-1).minus(negative, lrType); // -1-negative if (unsigned) { if (min == 0) { positiveResult = positiveResult.join(negative); if (max == 0) return positiveResult; min++; } // for x < 0, y > 0, x >>> y = (MAX_VALUE - ((-1-x) >> 1)) >> (y-1) negativeResult = point(lrType.max()).minus(negativeComplement.shrPositive(1, 1, lrType), lrType) .shrPositive(min - 1, max - 1, lrType); } else { negativeResult = point(-1).minus(negativeComplement.shrPositive(min, max, lrType), lrType); } return positiveResult.join(negativeResult); }