Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

ToExpresssion doesn't understand real numbers of the form "1.34e5". How do I convert the string "1.34e5" to a real number in Mathematica?

share|improve this question

marked as duplicate by RunnyKine, m_goldberg, Oleksandr R., Jens, Szabolcs Jun 6 '14 at 22:34

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

I think this question is ill-posed. Mathematica does not normally produce numeric strings of the form in question. Therefore, it seems reasonable to presume the source of the string is external. Should that be the case, then the conversion would be best handled during import. However, becko gives us no information about the source, essentially prohibiting the use of Mathematica;s import mechanisms to solve the problem. – m_goldberg Jun 6 '14 at 22:11
ImportString["1.34e5", "Table"][[1, 1]] – ciao Jun 6 '14 at 22:21
ImportString["1.34e5", "JSON"] – m_goldberg Jun 6 '14 at 22:25
@RunnyKine - maybe its a duplicate, but this question should remain opened for a while (there are many new users like myself). – eldo Jun 6 '14 at 22:27
@m_goldberg The source is a file containing rows of numbers. All rows are not of the same size, so it is not a matrix (therefore Import with option "Table" doesn't work). If that's relevant I can add it to the question. – becko Jun 6 '14 at 22:33
up vote 3 down vote accepted

Possibly the simplest solution is

ImportString["1.34e5", "JSON"]



share|improve this answer
It is short, yes, but I don't understand it. – eldo Jun 6 '14 at 22:32
@eldo. Added references you might want to look at – m_goldberg Jun 6 '14 at 23:12
@m_goldberg Your first link got removed. – Shawnic Hedgehog Mar 24 '15 at 20:31
@Saturisk. Thanks for pointing out the broken link. I have repaired it. – m_goldberg Mar 25 '15 at 3:59

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