admin管理员组文章数量:1026104
I need some help how to make this math formula in javascript. i have tried searching but couldn't really find cause i dont even know what ^ is called in English.
Thanks in advance
Math.floor(20*(1.1^(x-10)));
I need some help how to make this math formula in javascript. i have tried searching but couldn't really find cause i dont even know what ^ is called in English.
Thanks in advance
Math.floor(20*(1.1^(x-10)));
Share
Improve this question
edited Aug 1, 2015 at 6:42
user2864740
62.1k15 gold badges158 silver badges229 bronze badges
asked Jan 28, 2013 at 20:44
LilithLilith
613 bronze badges
3
- 3 Here's the Math object documentation. – Pointy Commented Jan 28, 2013 at 20:45
-
5
a^b
does not raisea
to theb
power in JavaScript. You'll want to useMath.pow
. – zzzzBov Commented Jan 28, 2013 at 20:45 -
In English, people generally say
A^B
asA to the Bth power
. In your case,1.1 to the (x minus 10)th power
. See also Exponentiation: en.wikipedia/wiki/Exponentiation – DACrosby Commented Jan 28, 2013 at 20:51
4 Answers
Reset to default 3Math.floor(20*(Math.pow(1.1, (x-10))));
^
is the bitwise XOR
operator - not what you want. Use the Math.pow
function for exponentiation:
Math.floor( 20 * (Math.pow(1.1, x - 10)) );
Set this up in a function so you can use x
for whatever value it may be:
var eq = function(x) {
return Math.floor( 20 * (Math.pow(1.1, x - 10)) );
};
Math.pow()
is what you are looking for.
^
, as used in other languages, is called the power or exponential operator, but in Javascript, it serves a different purpose, it is the bitwise XOR operator.
Math.floor(20*(Math.pow(1.1, x - 10)));
I need some help how to make this math formula in javascript. i have tried searching but couldn't really find cause i dont even know what ^ is called in English.
Thanks in advance
Math.floor(20*(1.1^(x-10)));
I need some help how to make this math formula in javascript. i have tried searching but couldn't really find cause i dont even know what ^ is called in English.
Thanks in advance
Math.floor(20*(1.1^(x-10)));
Share
Improve this question
edited Aug 1, 2015 at 6:42
user2864740
62.1k15 gold badges158 silver badges229 bronze badges
asked Jan 28, 2013 at 20:44
LilithLilith
613 bronze badges
3
- 3 Here's the Math object documentation. – Pointy Commented Jan 28, 2013 at 20:45
-
5
a^b
does not raisea
to theb
power in JavaScript. You'll want to useMath.pow
. – zzzzBov Commented Jan 28, 2013 at 20:45 -
In English, people generally say
A^B
asA to the Bth power
. In your case,1.1 to the (x minus 10)th power
. See also Exponentiation: en.wikipedia/wiki/Exponentiation – DACrosby Commented Jan 28, 2013 at 20:51
4 Answers
Reset to default 3Math.floor(20*(Math.pow(1.1, (x-10))));
^
is the bitwise XOR
operator - not what you want. Use the Math.pow
function for exponentiation:
Math.floor( 20 * (Math.pow(1.1, x - 10)) );
Set this up in a function so you can use x
for whatever value it may be:
var eq = function(x) {
return Math.floor( 20 * (Math.pow(1.1, x - 10)) );
};
Math.pow()
is what you are looking for.
^
, as used in other languages, is called the power or exponential operator, but in Javascript, it serves a different purpose, it is the bitwise XOR operator.
Math.floor(20*(Math.pow(1.1, x - 10)));
本文标签: mathHow to write Mathematical formula with quotquot (caret) in JavaScriptStack Overflow
版权声明:本文标题:math - How to write Mathematical formula with "^" (caret) in JavaScript? - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745634303a2160350.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论