在 C# 中,如何为方程分配上标?
我有一个方程,要求一个数字与其自身相乘给定的次数, 比如:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 C# 中,
^
是“异或”运算符。 对于求幂,您需要使用Math.Pow()
:double d = Math.Pow(2, 5);
In C#,
^
is the 'exclusive or' operator. For exponentiation you need to useMath.Pow()
:double d = Math.Pow(2, 5);
使用
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.