Problem with FPU and double calculation

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Problem with FPU and double calculation

1,451 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by h.lotfi on Wed Oct 15 01:22:12 MST 2014
Hi,
i have problem with hardware fpu and double calculation!

when i use float variables and enable FPU and initialize it, i can calculate any things, but when i change variables to double the micro  
get stick in the line which I calculate double variables and micro could not pass that line!!!
this is my code:
 double f=, ff=;
 //float f, ff;
        count = 0; // init counter
f = 1.000001;// pick initial values that will prevent over/under-runs
ff = 0.999999;
msec = 10000;// run the test for ten seconds
do {
//ff *= f;// test of multiplication
ff =ff/ f;// test of division
count++;
count /= 10;
} while(msec);


but when i add an function micro work correctly!!!
this code Work:
 double f=, ff=;
 //float f, ff;
        count = 0; // init counter
f = 1.000001;// pick initial values that will prevent over/under-runs
ff = 0.999999;
msec = 10000;// run the test for ten seconds
do {
               sprintf(str,"Num:%d\r\n",count);
//ff *= f;// test of multiplication
ff =ff/ f;// test of division
count++;
count /= 10;
} while(msec);



any body know what its for?

i use LPC4357 and Keil
标签 (1)
0 项奖励
回复
5 回复数

1,429 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by h.lotfi on Sat Oct 18 05:11:55 MST 2014
in may main code i write:
double f=0, ff=0;

thank you , i will try to understand assembly
0 项奖励
回复

1,429 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by starblue on Wed Oct 15 06:48:20 MST 2014

Quote: h.lotfi

 double f=, ff=;


That doesn't look like valid C code, maybe you are confusing several versions of your code?

When I have this kind of problem I look into the assembly code.
0 项奖励
回复

1,429 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by wmues on Wed Oct 15 05:21:46 MST 2014
I assume that you do ... while() loop is optimized away by the compiler, because no variable is used outside the loop.

The loop is endless? I missed a msec--.

regards
Wolfgang
0 项奖励
回复

1,429 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by h.lotfi on Wed Oct 15 04:19:36 MST 2014
of course i knew!
my question is,"why when i use double calculating micro stick on that line?"
and "why when i add another function in my loop system work correctly?"
i showed example of this questions in first post.
0 项奖励
回复

1,429 次查看
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by TheFallGuy on Wed Oct 15 02:02:54 MST 2014
Did you know that the FPU on the LPC43xx is single-precision (float) only. So for anything involving double-precision, the result has to be calculated in software. Therefore any calculation involving a double precision number will be very, very slow compared with a float.
0 项奖励
回复