在 C# 中,如何为方程分配上标?

发布于 2024-07-25 01:03:46 字数 197 浏览 4 评论 0原文

我有一个方程,要求一个数字与其自身相乘给定的次数, 比如:

 2 ^ 5

but if i implement the carrot '^' sign it doesnt give the required result ...

我做错了吗?

如果是的话,正确的表达方式是什么?

i have an equation that requires a number to be multiplied by itself for the given number of times ,
like:

 2 ^ 5

but if i implement the carrot '^' sign it doesnt give the required result ...

am i doing it wrong ?

if so what will be the correct expression for it?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冷︶言冷语的世界 2024-08-01 01:03:46

在 C# 中,^ 是“异或”运算符。 对于求幂,您需要使用 Math.Pow()

double d = Math.Pow(2, 5);

In C#, ^ is the 'exclusive or' operator. For exponentiation you need to use Math.Pow():

double d = Math.Pow(2, 5);

内心旳酸楚 2024-08-01 01:03:46

使用 Math.Pow(2, 5)

胡萝卜符号“^”用于布尔和按位异或运算。 你用来计算功率的想法来自VB/VB.NET。

Use Math.Pow(2, 5)

The carrot sign "^" is used for boolean and bitwise exclusive-OR operations. Your idea that it's used to calculate the power comes from VB/VB.NET.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文