返回值指针是double类型的数组也不能接受,后来改成long类型。数值都对了,但是精度达不到小数点后两位或三位。
求大神将我怎么去掉高位数值,我需要小数点前4到5位,小数点后2到3位。拜托了。
单片机源码:
- void process(double a,double b,double z,double *back_sp)
- {
- double xdata a,b,c;
- double xdata N1,M1,J1,G1,H1;
- J1=B1-zwx_d;
- J1*=0.0174532925199;
- G1=J1*J1;
- M1=A1*0.0174532925199;
- H1=sin(M1);
- M1=cos(M1);
- N1=M1*M1;
- a=(32144.5189-(135.3646-(0.7034-0.0041*N1)*N1)*N1);
- b=(0.25+0.00253*N1)*N1;
- b=b-0.04167;
- c=0.167*N1-0.083;
- c=c*N1;
- c=c*G1;
- c+=b;
- c*=G1;
- c+=0.5;
- c*=G1;
- b=108.996-0.603*N1;
- b=b*N1;
- b=21565.045-b;
- b*=N1;
- b=6399596.652-b;
- b=b*c;
- a=a-b;
- back_sp[0]=111133.00468*A1-a*M1*H1;
- a=0.001123*N1;
- a+=0.3333333;
- a*=N1;
- a-=0.1666667;
- b=0.1702-0.20382*N1;
- b*=N1;
- b=0.00878-b;
- b*=G1;
- a+=b;
- a=a*G1;
- a+=1;
- a*=J1;
- b=108.996-0.603*N1;
- b*=M1;
- b=21565.045-b;
- b*=N1;
- b=6399596.652-b;
- back_sp[1]=500000+a*b*M1;
- }
复制代码
|