简体   繁体   English

将excel公式转换为javascript - Math.pow()?

[英]Converting excel formula to javascript - Math.pow()?

I have the following formula in Excel. 我在Excel中有以下公式。

F14 = 100000 F14 = 100000

F15 = 10 F15 = 10

F16 = 10 F16 = 10

=(((1+F16)^(1/12)-1)*F14)/(1-((1+((1+F16)^(1/12)-1))^(-F15*12)))

This results in 1,297.75 which is correct. 这导致1,297.75这是正确的。 Simply trying to use the same formula in js gives a result of 8800, obviously wrong. 简单地尝试在js中使用相同的公式得到8800的结果,显然是错误的。

As I understand it, ^ should be replaced by Math.pow(A,B), correct? 据我了解,^应该被Math.pow(A,B)取代,对吗? Even so, I'm having real trouble making this out correctly. 即使这样,我也很难正确地解决这个问题。

Could anybody help me out? 有人可以帮帮我吗?

EDIT: Everything is good. 编辑:一切都很好。 The formula I posted was slightly different than the one in excel (don't know how i made that happen). 我发布的公式与excel中的公式略有不同(不知道我是如何实现的)。 Everything is good and makes sense now. 一切都很好,现在才有意义。 Thanks everybody 谢谢大家

In my Excel, I get the value of 22118,85503 and so does this 在我的Excel中,我得到22118,85503的值,所以这样做

 var F14 = 100000, F15 = 10, F16 = 10; console.log(((Math.pow(1 + F16, 1 / 12) - 1) * F14) / (1 - (Math.pow(1 + (Math.pow(1 + F16, 1 / 12) - 1), -F15 * 12)))); 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM