如何写有“^”在JavaScript(尖)数学公式?(How to write Mathematic

2019-08-08 14:59发布

我需要一些帮助,如何让在JavaScript这个数学公式。 我试图寻找,但未能真正找到原因我不知道什么是^叫英语。

提前致谢

Math.floor(20*(1.1^(x-10)));

Answer 1:

Math.floor(20*(Math.pow(1.1, (x-10))));


Answer 2:

^是按位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)) );
};


Answer 3:

Math.pow()是你在找什么。

^ ,如在其他语言中使用的,被称为功率或指数运算符,但在JavaScript中,它的目的不同,它是按位异或运算符。



Answer 4:

Math.floor(20*(Math.pow(1.1, x - 10)));


文章来源: How to write Mathematical formula with “^” (caret) in JavaScript?