我需要一些帮助,如何让在JavaScript这个数学公式。 我试图寻找,但未能真正找到原因我不知道什么是^叫英语。
提前致谢
Math.floor(20*(1.1^(x-10)));
我需要一些帮助,如何让在JavaScript这个数学公式。 我试图寻找,但未能真正找到原因我不知道什么是^叫英语。
提前致谢
Math.floor(20*(1.1^(x-10)));
Math.floor(20*(Math.pow(1.1, (x-10))));
^
是按位XOR
操作者-不是你想要的。 使用Math.pow
的幂函数:
Math.floor( 20 * (Math.pow(1.1, x - 10)) );
在功能设置此所以你可以使用x
的任何值可能是:
var eq = function(x) {
return Math.floor( 20 * (Math.pow(1.1, x - 10)) );
};
Math.pow()
是你在找什么。
^
,如在其他语言中使用的,被称为功率或指数运算符,但在JavaScript中,它的目的不同,它是按位异或运算符。
Math.floor(20*(Math.pow(1.1, x - 10)));