Is it possible to make printf print float values like 5.301 and 2.01 without printing extra zeros on the end?
Thanks.
Printable View
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
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