#include <iostream> #include <iomanip> int main() { float a = 1.f; std::cout << std::showpoint << a << ' ' << a/3; } Output with a different number of characters (7 and 8):
1.00000 0.333333
With other numbers:
#include <iomanip> int main() { float a = 10.f; // не 1.f std::cout << std::showpoint << a << ' ' << a/3; } Output with the same number of characters (7 and 7):
10.0000 3.33333
Why is that? How to always get the same number of characters? I need it for a nice console output / formatted file.
setwdo not want to use for alignment? All the same align by reducing the number of decimal places - in fact, moving the comma - ugly ... - Harrysetwwork withfloat? It turns out a different number of characters - violet