I have old C code that I am trying to reproduce in C ++. It uses printf modifiers: "% 06.02f".
I naively thought that iomanip was just as capable and did:
cout << setfill('0') << setw(6) << setprecision(2)
When I try to print the test number 123.456, printf gives:
123.46
But cout gives:
1.2 + E02
Is there anything I can do in iomanip to reproduce this, or should I revert to using printf ?
[ Live example ]
c ++ floating-point printf cout modifiers
Jonathan mee
source share