Avoid some overflow situations in lcm and rational +, -, rem, mod.
Merge pull request #3382 from GunnarFarneback/rational

Avoid some rational overflow