Code:
#include "Unit1.h" #include "math.h" #include "fixed_math.hpp" #include "algorithm.h" #define MBIT 0x4000 #define CBIT 16 long constbl[CBIT]; void __fastcall TForm1::Button1Click(TObject *Sender) { AnsiString buf; int i; long lx,ly, lz; float fz,x,y; void cordic(); x=1.0; for (i=0; i<CBIT; i++) { constbl[i]=atan(x)*MBIT; x *=0.5; } Memo1->Lines->Add("CORDICのよるarctanの計算"); Memo1->Lines->Add("tanの値はYとXの比で入力する"); Memo1->Lines->Add("正し 0<=Y<=1, 0<=X<=1とする"); for(;;) { Memo1->Lines->Add("Y=?"); Memo1->Lines->Add(buf.sprintf("%5.2f",y)); Memo1->Lines->Add("X=?"); Memo1->Lines->Add(buf.sprintf("%5.2f",x)); if ( x>1.0 || x<0.0) exit (0); if ( y>1.0 || y<0.0) exit (0); lx = x*MBIT; ly = y*MBIT; lz = 0; [B]cordic(lx,ly,lz);[/B] ------> in this line causing error fz = (float)lz/MBIT; Memo1->Lines->Add(buf.sprintf("arctan(y/x)=%5.2f",fz)); } } /* CORDIC m=1, y-->0 */ void cordic(x,y,z) long *x, *y, *z; { int i; long xx, yy, zz; for(i=0; i<CBIT ; i++) { if( *y>=0) { xx = *x + (*y>>i); yy = *y - (*x>>i); zz = *z + constbl[i]; } else { xx = *x - (*y>>i); yy = *y + (*x>>i); zz = *z - constbl[i]; } *x = xx; *y = yy; *z = zz; } }
I dont understand? because in the cordic function i declare it with three parameters and i`m calling cordic function with 3 parameters too..so where`s the problem??
Comment