How to output floating point numbers with a custom output format in C++?
- by Victor Liu
The problem is that I want to output Mathematica compatible floating point numbers. The only difference with the standard IOStream or printf output format is that the exponential e is replaced by *^:
Standard C/C++ output format: 1.23e-4
Mathematica format: 1.23*^-4
Is there a way to manipulate streams to achieve this effect? My original idea was just to use istringstream and dump it to a string and then replace all the e's. I would also be okay if someone posted code to parse through the bits of the floating point number and output it directly (i.e. a printf("%e") replacement).