如何用“^”来编写数学公式(插入符号)在JavaScript中? [英] How to write Mathematical formula with "^" (caret) in JavaScript?

查看:108
本文介绍了如何用“^”来编写数学公式(插入符号)在JavaScript中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助,如何在javascript中制作这个数学公式。我试过搜索但是找不到原因我甚至不知道^用英语叫什么。

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.

提前致谢

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


推荐答案

^ 是按位 XOR 运算符 - 不是你想要的。使用 Math.pow 函数进行取幂:

^ 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)) );

在函数中设置这个以便你可以使用 x 无论价值如何:

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)) );
};

这篇关于如何用“^”来编写数学公式(插入符号)在JavaScript中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆