Timeline for How do you convert a string containing a number in C scientific notation to a Mathematica number?
Current License: CC BY-SA 3.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Aug 3, 2019 at 8:24 | comment | added | Ruslan |
You can actually replace "*10^" with "*^" , which would be the Mathematica's syntax for floating-point exponents. E.g. InputForm[N[5^-9]] will give you 5.12*^-7 as the output.
|
|
Feb 14, 2012 at 14:01 | comment | added | PlatoManiac |
@Szabolcs thanks for explaining the issue with ToExpression . Your implementation is pretty cool. I did not know about the function StringToStream thanks for introducing...
|
|
Feb 14, 2012 at 13:55 | comment | added | Szabolcs |
It works, but let me give one comment: whenever you use ToExpression on data read from a file, you make it possible to inject code into a program even inadvertently (one can never tell what sort of erroneous input the program might get by mistake). I generally try not to use ToExpression for just reading in data (as opposed to converting code)
|
|
Feb 14, 2012 at 13:51 | comment | added | PlatoManiac | Still this is not fully correct! If numbers like 2.12 is represented as "2.12e" than the expected "2.12e1". MMA does so as I mentioned in the above comment on the answer given by @J.M | |
Feb 14, 2012 at 13:48 | history | edited | PlatoManiac | CC BY-SA 3.0 |
Corrected
|
Feb 14, 2012 at 13:21 | history | answered | PlatoManiac | CC BY-SA 3.0 |