Is there a standard way of formatting a float (or double) in C++ in decimal with exactly enough precision to parse it back to the same bits?
That is, I want 1.F
to be "1.0"
and 2.002f
to be "2.002"
.
For cases, where decimal is inexact another format would be acceptable (scientific or even hex float). Does such a case exist?
All I can find is reference to std::fixed
and std::setprecision
such as this link. The precision is fixed for these.
Thanks.