LongRangeSet (long mod, LongRangeSet remainders) { if (remainders.isEmpty()) return empty(); long min = remainders.min() > 0 ? 1 : Long.MIN_VALUE; long max = remainders.max() < 0 ? -1 : Long.MAX_VALUE; if (mod > 1 && mod <= Long.SIZE) { long bits = remainders.contains(0) ? 1 : 0; for(int rem = 1; rem < mod; rem++) { if (remainders.contains(rem) || remainders.contains(rem - mod)) { bits = setBit(bits, rem); } } return modRange(min, max, mod, bits); } return range(min, max); }