Here's an example of round-off differences :
This is a function to build a hamming window that is calculated using 32-bit floats, which then converts it to q15 :
void hamming_window_q15(q15_t *finalarray) {
float32_t temp_vals[SPEC_FFT_SIZE];
float32_t bigN = (float32_t)SPEC_FFT_SIZE;
int i = 0;
for(i = 0; i < SPEC_FFT_SIZE; i++){
//temp_vals[i] = .54 - .46 * cos(2*PI (i / bigN));
temp_vals[i] = 0.54 - 0.46 * cos(2.0*PI*(((float32_t)i) / bigN));
}
arm_float_to_q15(temp_vals, finalarray, SPEC_FFT_SIZE);
}
^SPEC_FFT_SIZE is 1024.
The first values I get is 2622.
Using rounding in Matlab, I get these values for my hamming window, the round to achieve what would be equivalent to the binary of the q15 : { 2621, 2622, 2623, 2624, 2626, 2629, 2632, 2635,...
So you see the small differences that will arise when you do Matlab (generally 64 bit precision depending on your machine) versus fractional integers. The point is, expect imprecision when you use fractional integers.