I am working with a Fortran program that expects floating point numbers to be input using Fortran's E
format specifier, which is scientific notation, except the mantissa must be between 0 and 1. So instead of:
"3147.3" --> "3.1473E3",
it needs
"3147.3" --> "0.31473E4".
I am unable to modify the Fortran program, as it works with a few other programs that are also particular.
It would appear that the C# E
format string would give me the former. Is there any simple way to achieve the latter in C#?
You could specify a custom format like so.
var num = 3147.3;
num.ToString("\\0.#####E0"); // "0.31473E4"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With