I have a set of doubles. I don't want to print the extra zeroes at the end, just the relevant part. Problem is, each double has a different fractional part. Take a look at some code below:
Code:
double x, y, z;
x = 1.2;
y = 1.45;
z = 7;
printf("x is %f, y is %f, and z is %f", x, y, z);
The output of that program will be something like:
x is 1.200000000, y is 1.45000000000, and z is 7.000000000000
I would like it to print "x is 1.2, y is 1.45, and z is 7"
Anyone have any ideas?
EDIT: Thanks, matsp, for pointing out about x. I changed that.