Is it possible to make printf print float values like 5.301 and 2.01 without printing extra zeros on the end?
Thanks.
Is it possible to make printf print float values like 5.301 and 2.01 without printing extra zeros on the end?
Thanks.
What's wrong with %f? it does not print zeroes at the end.
Be more specific what you want to get
All problems in computer science can be solved by another level of indirection,
except for the problem of too many layers of indirection.
– David J. Wheeler
printf( "%.2f", .650 );
will print .65 substitute the 2 with 3 or however many digits you want. Keep in mind that it will always be that many digits.
So,
printf( "%.2f", .656 );
will print .66
Not sure if there's a way to make it expand.
//The OPs statement does print zeros on my machine.
glibc version 2.6.1
Last edited by krock923; 12-08-2007 at 12:42 AM.