class MaskedLong implements Comparable<MaskedLong> {

	public MaskedLong invShiftRight(long n) throws SolverException {
		if (n == 0) {
			return this;
		}
		long checkVal = (Long.MIN_VALUE >> n) & val;
		long checkMsk = (Long.MIN_VALUE >> n) & msk;
		if (checkMsk == 0) { // All fallen bits and sign bit unknown
			return new MaskedLong(msk << n, val << n);
		}
		// All defined bits must match.
		// Additionally, if the resulting sign bit is undefined, but any fallen bit is defined,
		// then the sign bits is actually defined
		if (checkVal == 0) { // All known (of fallen and sign bits) zero
			return new MaskedLong(msk << n | Long.MIN_VALUE, val << n);
		}
		if (checkVal == checkMsk) { // All known (of fallen and sign bits) one
			return new MaskedLong(msk << n | Long.MIN_VALUE, val << n | Long.MIN_VALUE);
		}
		throw new SolverException(
			"Cannot invert arithmetic right shift where bits to the left disagree");
	}

	protected  MaskedLong(long msk, long val);

}