开发者

please help with this error : Operator '^' cannot be applied to operands of type 'double' and 'int'

i have the following 开发者_如何学PythonC# code.

double a = 0;
 double d = 0;
double er = 0;
int N = numbers.Length;
a=(N*N/6) + N
d=(N-(N/2))*2



     for(int aa=1;aa<=data.length;aa++)
        {

              er=((10-aa)*(-a\) + d - (numbers[aa,12]))^2;

          }

numbers is a double array with this format :

1 0.3232 0.361 0.5214 0.233 -0.7678
2 0.3451 0.321 0.134 0.224 -0.706268
3 0.3123 0.351 0.155 0.523 -0.70626
4 0.36 0.312 0.216 0.233 -0.6453351
5 0.269 0.3331 0.162 0.224 -0.584962

but when running the code , i got this error on this line:

 er=((10-aa)*(-a\) + d - (numbers[aa,12]))^2;

any help would be appreciated.


Use Math.Pow - the ^ is not the power operator, it is a logical XOR operator.

There is no power operator in c#.


I'm not sure what you're intending to use the ^ operator for, but in C,C++, and C# it is the xor operator. Its not defined for non-integral types. If youre trying to do an exponential, you're better off using something like Math.pow() or doing the multiplication yourself

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜