Checking if two intervals overlap is covered on this page:
http://www.rgrjr.com/emacs/overlap.html
which shows intervals
overlap if
If the intervals are specified by a width
then the overlap test is
The expression
is equivalent to evaluating
and checking that the result is negative by examining the sign bit.
So this expression is negative if the intervals overlap: