C++ How to output number with at least one number behind the decimal mark
How can I make my program output a number with at least one number behind the decimal mark C++? Output: 1 = 1.0 or 1.25 = 1.25 or 2.2 = 2.2 or 3.456789 = 3.456789 Thanks in advance Use showpoint to force the decimal point to be printed double x = 1.0; std::cout << std::showpoint << x << "\n"; It will be followed by the number of 0 required to satisfy the precision of the stream. #include <cmath> #include <iostream> #include <limits> struct FormatFloat { static constexpr const double precision = std::sqrt(std::numeric_limits<double>::epsilon()); const double value; FormatFloat(double value) :