Fixed a few cases in the Math functions where floating point impresission caused integral math to yield incorrect results. Fixes #2893.