I am using xc8 v1.35 and MPLABX V3.2 and an 18f2420 pic. I have set double to be 32 bits.
I have the digits of a frequency stored in an interger array.
int freq[]
{ 0,0,0,0,0,0,0,0}
I calculate the frequency thus
long frequency = 0;
freq[7] * 1 +
freq[6] * 10 +
freq[5] * 100 +
freq[4] * 1000 +
freq[3] * 10000 +
freq[2] * 100000 +
freq[1] * 1000000 +
freq[0] * 10000000;
However if I have
freq = {0,0,5,8,0,0,0,0}
and do the caluclation
I get 514614 instead of 580000
What stupid mistake am I making.
John
I have the digits of a frequency stored in an interger array.
int freq[]
{ 0,0,0,0,0,0,0,0}
I calculate the frequency thus
long frequency = 0;
freq[7] * 1 +
freq[6] * 10 +
freq[5] * 100 +
freq[4] * 1000 +
freq[3] * 10000 +
freq[2] * 100000 +
freq[1] * 1000000 +
freq[0] * 10000000;
However if I have
freq = {0,0,5,8,0,0,0,0}
and do the caluclation
I get 514614 instead of 580000
What stupid mistake am I making.
John