transitive comparison of floats and rationals

Closes #3102.