Not my code, but you have a point. It is certainly easy to overlook those traps in someone else's!

Curiously, using Code::Blocks/gcc on the PC as I was, it does not make any difference to the overall result to cast rawData[] as long, i.e.

`sum += ( (long) rawData[k]) * ( (long) rawData[k+i]);`

It appears that on the PC, Code::Blocks promotes the type char to a larger integer for the purpose of the multiplication. I haven't yet figured out how to view the machine code listing to check this supposition, so I printed out the first few values of rawData[]*rawData[] using the following statement:

` fprintf(fp,"%d,%d,%d\n",i,rawData[i],rawData[i]*rawData[i]);`

and got the following values:

0,115,13225

1,126,15876

2,62,3844

3,57,3249

4,-80,6400

5,77,5929

Clearly, the multiplication is not overflowing the char data type. So, I don't see why Matlab would give a "much different result" for the autocorrelation function (why not show us what it is?).