Make interval arithmetic handle empty intervals gracefully
Right now if you have two intervals a
and b
and one of them is empty, the operations a + b
and a - b
throw an ArgumentOutOfRangeException.
. Making these operations simply return an empty interval instead would simplify calling code and actually fits the semantics of intervals well ("The sum of a
and b
is the interval of all values x + y
for x
from a
and y
from b
").
I therefor suggest we make these operation return empty intervals in said case. I already tried to check if the exceptions are handled anywhere, which does not seem to be the case.
Any reason not to do it?