Esempio n. 1
0
        public void TestNper()
        {
            double f, r, y, p, x, n;
            bool   t = false;

            r = 0; y = 7; p = 2; f = 3; t = false;
            n = FinanceLib.nper(r, y, p, f, t);
            x = -0.71428571429; // can you believe it? excel returns nper as a fraction!??
            Assert.AreEqual(x, n, 0.0000000001);

            // cross check with pv
            r = 1; y = 100; p = -109.66796875; f = 10000; t = false;
            n = FinanceLib.nper(r, y, p, f, t);
            x = 10;
            Assert.AreEqual(x, n, 0.01);

            r = 1; y = 100; p = -209.5703125; f = 10000; t = true;
            n = FinanceLib.nper(r, y, p, f, t);
            x = 10;
            Assert.AreEqual(x, n, 0.1);

            // cross check with fv
            r = 2; y = 120; f = -6409178400d; p = 12000; t = false;
            n = FinanceLib.nper(r, y, p, f, t);
            x = 12;
            Assert.AreEqual(x, n, "nper ");

            r = 2; y = 120; f = -6472951200d; p = 12000; t = true;
            n = FinanceLib.nper(r, y, p, f, t);
            x = 12;
            Assert.AreEqual(x, n, "nper ");
        }
Esempio n. 2
0
 public override double Evaluate(double rate, double arg1, double arg2, double arg3, bool type)
 {
     return(FinanceLib.nper(rate, arg1, arg2, arg3, type));
 }