本文介绍了有没有在C#中的指数运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如,确实运营商存在来处理呢?

For example, does an operator exist to handle this?

float Result, Number1, Number2;

Number1 = 2;
Number2 = 2;

Result = Number1 (operator) Number2;

在过去 ^ 运营商曾担任在其他语言中的指数运算符,但在C#这是一个逐位运算符。

In the past the ^ operator has served as an exponential operator in other languages, but in C# it is a bit-wise operator.

我必须写一个循环或包含另一个命名空间来处理指数操作?如果是这样,我怎么处理使用非整数的指数操作?

Do I have to write a loop or include another namespace to handle exponential operations? If so, how do I handle exponential operations using non-integers?

推荐答案

C#语言的。但是,.NET框架提供方式:

The C# language doesn't have a power operator. However, the .NET Framework offers the Math.Pow method:

返回提高到指定的电源中指定数量。

所以,你的例子是这样的:

So your example would look like this:

float Result, Number1, Number2;

Number1 = 2;
Number2 = 2;

Result = Math.Pow(Number1, Number2);

这篇关于有没有在C#中的指数运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 23:52