Javascript IRR (Internal rate of return) Formula Accuracy

后端 未结 7 1683
名媛妹妹
名媛妹妹 2021-02-04 20:00

I\'m using a IRR function in javascript to create calculation a that is done in excel using its own IRR function. The problem is mine is little off and I have no idea why. Here\

7条回答
  •  甜味超标
    2021-02-04 20:50

    We modified the code to achieve performance and accuracy. Try this:

    function IRRCalc(CArray) {
    
      min = 0.0;
      max = 1.0;
      do {
        guest = (min + max) / 2;
        NPV = 0;
        for (var j=0; j 0) {
          min = guest;
        }
        else {
          max = guest;
        }
      } while(Math.abs(NPV) > 0.000001);
      return guest * 100;
    }
    

提交回复
热议问题