MathGroup Archive 2003

[Date Index] [Thread Index] [Author Index]

Search the Archive

RE: Severe ToExpression Fault?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42903] RE: [mg42892] Severe ToExpression Fault?
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Sat, 2 Aug 2003 04:12:27 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

>-----Original Message-----
>From: nils at theune.com [mailto:nils at theune.com]
To: mathgroup at smc.vnet.net
>Sent: Friday, August 01, 2003 7:26 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg42903] [mg42892] Severe ToExpression Fault?
>
>
>Hi folks,
>
>running Mathematica 4.0.1 I am stuck with the following problem:
>
>Input:
>Print["-1,97E-04"];
>Print[StringReplace["-1,97E-04", {"," -> "."}]];
>Print[ToExpression[StringReplace["-1,97E-04", {"," -> "."}]]];
>
>Output:
>-1,97E-04
>-1.97E-04
>-9.35502
>
>Can somebody explain this to me? Why does the ToExpression Function
>not make the decimal -1.97E-04 out of the String "-1.97E-04". What in
>the hell is going wrong (-9.35502->"Where does this number come
>from?") and what can be done to circumvent the ToExpression function.
>
>I am greatful for any kind of comments on this problem/bug.
>
>regards
>Nils
>

No severe fault, a simple misunderstanding, compare:

In[1]:= -1.97E-04
Out[1]= -9.35502
 
In[2]:= -1.97 * E  - 4
Out[2]= -9.35502

In[3]:= -1.97*^-4
Out[3]= -0.000197

but Mathematica may understand the format you chose, if you specify the
right conversion:
 
In[5]:= Read[StringToStream["-1.97E-04"], Real]
Out[5]= -0.000197

--
Hartmut Wolf


  • Prev by Date: combinatorica to make something of a flowchart...
  • Next by Date: Re: Severe ToExpression Fault?
  • Previous by thread: Re: Severe ToExpression Fault?
  • Next by thread: Re: Severe ToExpression Fault?