Convert Fortran-like number form to traditional number form
Closest to sensible I can imagine would be wrapping these numbers individually with a function if e is always followed by sign (+
or -
):
ClearAll@fn;
fn[m_. e + e_] := m 10^e;
fn[m_. e] := m;
fn[_] := 0;
fn[1.13903 e - 08]
1.13903*10^-8
Handling the case where +
is implicit seems awfully convoluted to get right.
I also thought of redefining e
as an operator, but firstly I don't think arbitrary letters can be redefined that way, and secondly all hell would probably break loose if such a definition would be present globally.
An enhanced version of kirma's answer, which handles expressions like 5 e 4
:
ClearAll@fn;
SetAttributes[fn, HoldAll]
fn[m_. e + e_] := m 10^e
fn[a_. e b_] := a 10^b
fn[5 e 4]
(* 50000 *)
you are fighting with windmills.
Interpreter["Number"]["4.5E-7"]
gives you 4.5*10^-7