If you're using Windows and MinGW, then you have to do some work for printing long double -- I think I've posted this code here before as a quick-and-dirty way to see the numbers:
Code:
char *printf_ld(long double arg, char answer[15]) {
/* For my own sake: scientific notation with six digits */
double mantissa, exponent, lg;
lg = log10l(fabs(arg));
exponent = floor(lg);
mantissa = pow(10, lg-exponent);
mantissa = copysign(mantissa, arg);
sprintf(answer, "%.6fe%+04g", mantissa, exponent);
return answer;
Now that that's out of the way, you actually don't want to do this in the way you are doing -- if you ever keep a number bigger than 1000, you're doing it wrong.