public boolean isInRange(long max, boolean signed) {
		if (-1 == max) {
			return true; // Every long, signed or unsigned fits
		}
		long min = 0;
		if (signed) {
			max >>>= 1;
			min = ~max;
			long ckVal = signExtend().longValue();
			return min <= ckVal && ckVal <= max; // ---[--v--.--v--]---
		}
		// unsigned
		long ckVal = zeroExtend().longValue();
		if (max < 0) {
			return ckVal >= 0 || ckVal <= max; //   ---v--]--.[--v---
		}
		return ckVal >= 0 && ckVal <= max; //       ---.[--v--]---
	}
Check if the masked value falls within a given range

<p>
The range is defined by a maximum and a signedness. The maximum must be one less than a
positive power of 2. In other words, it defines a maximum number of bits, including the sign
bit if applicable.

<p>
The defined bits of this masked long are then checked to fall in the given range. The
effective value is derived by sign/zero extending the value according to its mask. In
general, if any {@code 1} bits exist outside of the given max, the value is rejected, unless
that {@code 1} is purely a result of signedness.

@param max the maximum value, taken as an unsigned long.
@param signed true to interpret the masked value as signed.
@return true if the masked value "fits" into the given range.
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/app/plugin/assembler/sleigh/expr/MaskedLong.java