c#Pow / Datatype转换

时间:2016-02-29 21:06:45

标签: c# .net

我对编程很新。在使用POW函数时,我已经阅读了大量关于转换数据类型的帖子并尝试注意。

我无法理解为什么以下内容不起作用。在调试器中,y被赋值为0.我无法理解为什么会这样。我认为这与我如何转换双打/小数有关?

 public decimal MonthsPayment(){
            decimal monthlyint = this.Rate / 12;
            int totalpayments = this.Term * 12;
            decimal x = monthlyint * this.Amount;

            decimal s1 = (1+monthlyint);
            decimal s2 = (-totalpayments);

            decimal y = (decimal)(Math.Pow((double)s1,(double)s2));
            decimal Repayment = x /(1 - y);
            return Repayment;

0 个答案:

没有答案
相关问题