Пример #1
0
        public void TestMod()
        {
            //example from Excel help
            Assert.AreEqual(1.0, MathX.Mod(3, 2));
            Assert.AreEqual(1.0, MathX.Mod(-3, 2));
            Assert.AreEqual(-1.0, MathX.Mod(3, -2));
            Assert.AreEqual(-1.0, MathX.Mod(-3, -2));

            Assert.AreEqual(0.0, MathX.Mod(0, 2));
            Assert.AreEqual(Double.NaN, MathX.Mod(3, 0));

            Assert.AreEqual((double)1.4, MathX.Mod(3.4, 2));
            Assert.AreEqual((double)-1.4, MathX.Mod(-3.4, -2));
            Assert.AreEqual((double)0.6000000000000001, MathX.Mod(-3.4, 2.0));  // should actually be 0.6
            Assert.AreEqual((double)-0.6000000000000001, MathX.Mod(3.4, -2.0)); // should actually be -0.6

            Assert.AreEqual(3.0, MathX.Mod(3, Double.MaxValue));
            Assert.AreEqual(2.0, MathX.Mod(Double.MaxValue, 3));

            // Bugzilla 50033
            Assert.AreEqual(1.0, MathX.Mod(13, 12));
        }