The attached patch shows how the LOGIOR bounds can be derived.
Joining the calculations for the low and the high bound allows sharing of work which makes the above-mentioned case with both arguments being (INTEGER 0 18446744073709551615) take only 50 percent more time than the orginal implementation (when both bounds are needed, which is always the case).
The algorithm runs in constant time if all arguments are fixnums and in linear time in the number of bignum digits otherwise.
The attached patch shows how the LOGIOR bounds can be derived.
Joining the calculations for the low and the high bound allows sharing of work which makes the above-mentioned case with both arguments being (INTEGER 0 184467440737095 51615) take only 50 percent more time than the orginal implementation (when both bounds are needed, which is always the case).
The algorithm runs in constant time if all arguments are fixnums and in linear time in the number of bignum digits otherwise.