SpeedBWild
Programmer
I am reading in a line of data so that I can insert the text data into an array. Here is my code:
double rate;
rate = atof (&wktxt[k]); /* &wktxt[k]=2.046 */
rate *= 1000.0;
prate[cin][x] = (long) rate;
The result of prate[cin][x] is 2045
I have hundreds of values in the text file all of them convert as expected except 2.046. If I add this line of
code rate += .00000000001; (see below) then it converts correctly.
rate *= 1000.0;
rate += .00000000001;
prate[cin][x] = (long) rate;
Any ideas? Has anyone else experienced anything like this before?
double rate;
rate = atof (&wktxt[k]); /* &wktxt[k]=2.046 */
rate *= 1000.0;
prate[cin][x] = (long) rate;
The result of prate[cin][x] is 2045
I have hundreds of values in the text file all of them convert as expected except 2.046. If I add this line of
code rate += .00000000001; (see below) then it converts correctly.
rate *= 1000.0;
rate += .00000000001;
prate[cin][x] = (long) rate;
Any ideas? Has anyone else experienced anything like this before?