jim mcnamara
Jul 17th, 2002, 04:54 PM
Do only double precision arithmetic. It's getting rounded if you convert to single precision.
const double g=.0000000000667;
double whatever, result
float someval;
result = whatever * g * convert(someval);
Note that most implementations of C and C++ don't do a good job of casting single to double - that's why:
double convert(float in){
double tmp;
char start[25], *end;
memset(start,0x00, sizeof(start));
sprintf(start,"%f",in);
end=s;
return strtod(s,&end);
}
const double g=.0000000000667;
double whatever, result
float someval;
result = whatever * g * convert(someval);
Note that most implementations of C and C++ don't do a good job of casting single to double - that's why:
double convert(float in){
double tmp;
char start[25], *end;
memset(start,0x00, sizeof(start));
sprintf(start,"%f",in);
end=s;
return strtod(s,&end);
}