Checking if two intervals overlap is covered on this page:

http://www.rgrjr.com/emacs/overlap.html

which shows intervals

(*s*_{1}, *e*_{1})

(*s*_{2}, *e*_{2})

overlap if

(*s*_{2} < *e*_{1})∧(*s*_{1} < *e*_{2})

If the intervals are specified by a width

(*s*_{1}, (*s*_{1} + *w*_{1}))

(*s*_{2}, (*s*_{2} + *w*_{2}))

then the overlap test is

(*s*_{2} < (*s*_{1} + *w*_{1}))∧(*s*_{1} < (*s*_{2} + *w*_{2}))

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:

(*s*_{2} − *s*_{1} − *w*_{1})∨(*s*_{1} − *s*_{2} − *w*_{2})