For C++ there's a nice boost::numeric::interval library that handles it.
https://www.boost.org/doc/libs/1_66_0/libs/numeric/interval/...