qpwoeiruty
February 21st, 2007, 09:58 PM
I've been trying to add an int+exponent to a long int by typecasting. No matter the combination, I can't seem to get the cout to work correctly. Usually, when the program is run, it outputs a value less than 10 instead of i*1e6+j*1e3+k.
As of now, I'm stuck...
The offending relevant code:
int origin, m, i, j, k;
long int step[50]={0};
x=y=z=origin=m=0;
srand(time(NULL)); //seed the RNG
//i, j, k are defined from 0 to 1000 by for loops
step[m] = (long int)(i)*(long int)(1000000);
step[m] += (long int)(j)*1000;
step[m] += (long int)(k);
m++;
for(int n=0; n<m; n++) {
cout << step[n] << endl;
}
}
As of now, I'm stuck...
The offending relevant code:
int origin, m, i, j, k;
long int step[50]={0};
x=y=z=origin=m=0;
srand(time(NULL)); //seed the RNG
//i, j, k are defined from 0 to 1000 by for loops
step[m] = (long int)(i)*(long int)(1000000);
step[m] += (long int)(j)*1000;
step[m] += (long int)(k);
m++;
for(int n=0; n<m; n++) {
cout << step[n] << endl;
}
}