I am looking for a possibility within C/C++ to print a float (or double) f, say f = 1.234e-15, such that it is printed as
f = 1.234*10^-15, or, even better, asf = 1.234*10^{-15}
Can anyone help me? Maybe there is a way to get the exponent “-15” and mantissa “1.234” in base 10. I found the question how can I extract the mantissa of a double, but unfortunately that did not really help, since it only gets the mantissa in base 2.
You can print to a
stringusing the output string stream, and then replace"e"with"*10^".This snippet produces