Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.
ToExpression["9.0E-03"]

interprets String as

9*e - 3

instead of what I am expecting

0.009

How can I convert to expression Fortran notation?

share|improve this question
1  
ToExpression[StringReplace["9.0E-03", "E" -> "*^"]] –  rasher May 23 at 7:11
    
@rasher thank you! –  user1541776 May 23 at 7:28

1 Answer 1

up vote 3 down vote accepted

You can use ImportString, with the "Table" or "List" argument. See the documentation for details.

ImportString["9.0E-03", "Table"]

(* {{0.009}} *)

or

ImportString["9.0E-03", "List"]

(* {0.009} *)
share|improve this answer
    
thank you! I'm a bit puzzled though with Mathematica's architecture: why is it a separate function and moreover contains Import in its title? –  user1541776 May 23 at 7:30
1  
ImportString takes a String as argument and provides the same output as Import, which takes a file as Argument. –  Markus Roellig May 23 at 7:37
    
thank you, now it's clear. –  user1541776 May 23 at 7:45

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.