Quote:
|
Originally Posted by Mark McLeod
To print floats you can always use a little manipulation like:
Code:
#define ACCURACY 1000 //How many decimal places are important to you
float f;
int i, i2; // Might need to be longs if you have a lot of significant digits
f = 245.56;
/* Print float value */
i = (int) f;
i2 = (int) ((f-i)*ACCURACY);
printf("f = %d.%d r", i, i2); //e.g., f = 245.559
|
You're going to want to be sure leading zeroes are printed for the fractional part. Does this printf implementation support "%03d"?