将Excel公式转换为JS时处理指数

时间:2015-10-28 19:44:35

标签: javascript excel pow

我有这个Excel公式:

(Assets*(1+Interest)^(CURRENT{age}+1‐Enrollment{age}))+(Salary*Employee{contribution}+Employer{contribution}))*((1+Interest)^(CURRENT{age}+1‐Enrollment{age})‐(1+Inflation)^(CURRENT{age}+1‐Enrollment{age}))/(Interest‐Inflation)

我试图将其转换为下面的JS公式:

age_assets = (assets*Math.pow(1+interest,age+1-enroll_age))+(salary*(your_contrib+employ_contrib))*(Math.pow(1+interest, age+1-enroll_age)-Math.pow(1+inflation, age+1-enroll_age))/(interest-inflation);

鉴于这些价值观:

// Age
           64,
// Retirement age
           67,
// Enrollment age
           30,
// Assets
           10000,
// Interest
           .3,
// Salary
           100000,
// Your contribution
           .10,
// Employer contribution
           .03,
// Inflation
           .02,
// Retirement type
           .85

电子表格的价值要小得多。有没有人看到这两个公式之间有任何不一致之处?我以前从来没有做过这种事。

0 个答案:

没有答案