I am a circuit designer, not a software engineer, so I have no idea how to track this issue.
I am working with some IIR filter code, and I am having problems with extremely slow runtimes when I process very small values ββthrough a filter. To find the problem, I wrote this test code.
Typically, the cycle will work after about 200 ms or so. (I did not measure it.) But when TestCheckBox-> Checked, it takes about 7 seconds to start. The problem is reducing the size of A, B, C, and D in the loop, which is exactly what happens with the values ββin the IIR filter after the input signal reaches zero.
I believe that the problem lies in the fact that the value of the exponential variable becomes less than -308. A simple fix is ββto declare the variables as doubles, but this is not a simple fix in the actual code, and it seems like I should not do this.
Any ideas why this is happening and what could be a simple fix?
In case of his questions, I use C ++ Builder XE3.
int j; double A, B, C, D, E, F, G, H;
EDIT: As the answers say, the cause of this problem is denormal math, which I have never heard of. Wikipedia has a pretty nice description, as does the MSDN article provided by Sneftel.
http://en.wikipedia.org/wiki/Denormal_number
Having said that, I still can't get my code to reset the denormals. The MSDN article says:
_controlfp(_DN_FLUSH, _MCW_DN)
These definitions are not in the XE3 math libraries, so I used
controlfp(0x01000000, 0x03000000)
in the article, but this does not affect XE3. The code is also not listed in the Wikipedia article.
Any suggestions?