错误是什么:二进制表达式的无效操作数(“double”和double“)是什么意思?

时间:2014-04-03 16:41:59

标签: binary double

第55行:我写的" V =(pow(vx,2)+ pow(vy,2))^ 0.5;"

我有错误:二进制表达式的操作数无效(" double"和double")。这是什么意思?

请帮忙!

int main() {

FILE *fp, *fopen();
fp=fopen("Orbit2", "w");

double M,G,y0,vx,vy,x,y,h,t,T,m,V, positionx,positiony,velocityx,velocityy,energy,kinetic,potential;
G=6.67*pow(10,-11);
h=1000;
m=7.345*pow(10,22);
t=0;
M=1.99*pow(10,30);
y=0;
y0=0;
x=1.5*pow(10,11);
vx=0;
vy=22350;
energy=kinetic+potential;

T=t+h;
for (T=0; T<110000; T++)
{

    printf("y=%lf,x=%lf\n", y,x);
    fprintf(fp,"%lf,%lf\n", y,x);

    V=(pow(vx,2)+pow(vy,2))^0.5;

    positionx=x+(h/(double)6.0)*((kx1(vx))+(2*kx2(G,M,h,x,y,vx))+(2*kx3(G,M,h,x,y,vx,vy))+(kx4(G,M,h,x,y,vx,vy)));
    positiony=y+(h/(double)6.0)*((ky1(vy))+(2*ky2(G,M,h,x,y,vy))+(2*ky3(G,M,h,x,y,vx,vy))+(ky4(G,M,h,x,y,vx,vy)));
    velocityx=vx+(h/(double)6.0)*((kvx1(G,M,x,y))+(2*kvx2(G,M,h,x,y,vx,vy))+(2*kvx3(G,M,h,x,y,vx,vy))+(kvx4(G,M,h,x,y,vx,vy)));
    velocityy=vy+(h/(double)6.0)*((kvy1(G,M,x,y))+(2*kvy2(G,M,h,x,y,vx,vy))+(2*kvy3(G,M,h,x,y,vx,vy))+(kvy4(G,M,h,x,y,vx,vy)));

    x=positionx;
    y=positiony;
    vx=velocityx;
    vy=velocityy;

    if ((fabs(positiony-y0)<100) && (fabs(positionx-x)<100))
    {
        break;
    }


}

fclose(fp);
return 0;

}

1 个答案:

答案 0 :(得分:0)

编译器抱怨你正在尝试将两个双打异或,这没有多大意义。更多细节可以在这里找到:How do I use bitwise operators on a "double" on C++?