1) setprecision will not show trailing zeroes, you are probably have std::fixed too
2) Now it works exactly like it should: prints 5 significant digits.
3) To have behavior you want, you can:
* detect leading zero and change precision before each output
* print number into stringstream and then print exact number of characters you want
* write your own print function.