I have a long program, which consists of one header file, and two source files, in the first one I have written the implementations of the functions, and in the second one (which is my main), I call and execute them. Though, at one point I get an error message saying
Floating point exception (core dumped)
and the program stops.
As I said there are lots of lines of code, therefore, I'm not able to post my whole source code here, though I will post the most relevant parts, and where error occurs.
My error occurs when I try to call this function (below you can find its implementation):
void chest_first(Complex* FFTInput, Complex* IFFTOutput, Complex* HFirst)
{
int i;
for(i = 0; i < 64; i++)
{
HFirst[i].real = FFTInput[i].real / IFFTOutput[i].real;
HFirst[i].imag = FFTInput[i].imag / IFFTOutput[i].imag;
}
}
In this case Complex, is a type definition that I have defined.
typedef struct {
int real, imag;
} Complex;
Here is the part from the main, where this function is called.
Complex HFirst[64];
if((strcmp(channel, "LS") == 0) || (strcmp(channel, "ls") == 0))
{
if(i == 1)
chest_first(fft_input, ifft_bpsk_output, HFirst);
.
.
.
}
I have earlier called some other function, which put values to fft_input and ifft_bpsk_output, which are both Complex arrays with 64 elements.
IFFTOutput[i].real
(or.imag
) is 0. (Or-1
, and the dividend isINT_MIN
is another possibility on some platforms.) Confusingly, an integer division by 0 gives rise toSIGFPE
. – Fleeting