M
Mandragon03
I am looking for a way to take a floating point number and get rid of
any extraneous 0's at the end. For instance if I have
myFloat = 9999;
printf("%f", myFloat);
I get 9999.0000. I want to get rid of these 0's.
Here is one catch. I also need to be able to do this:
myFloat = .531;
printf("%f", myFloat);
I get .5310000
I need to get .531.
I realize I can do this
printf("%2f", myFloat);
which will limit the mantissa to two places, but this will not work
for what i am doing because I can not lose that much precision on
floats like .05369.
Thank you for you time,
Mandragon03
any extraneous 0's at the end. For instance if I have
myFloat = 9999;
printf("%f", myFloat);
I get 9999.0000. I want to get rid of these 0's.
Here is one catch. I also need to be able to do this:
myFloat = .531;
printf("%f", myFloat);
I get .5310000
I need to get .531.
I realize I can do this
printf("%2f", myFloat);
which will limit the mantissa to two places, but this will not work
for what i am doing because I can not lose that much precision on
floats like .05369.
Thank you for you time,
Mandragon03