MathGroup Archive 2003

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

Search the Archive

Re: Severe ToExpression Fault?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg42920] Re: [mg42892] Severe ToExpression Fault?
  • From: Peter <peter1963 at totalise.co.uk>
  • Date: Sat, 2 Aug 2003 04:12:48 -0400 (EDT)
  • References: <200308010526.BAA09833@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Nils Theune wrote:
> 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
> 

Hi Niels,
according to the Mathematica book, section A.2.5, your last input should read:

Print[ToExpression[StringReplace["-1,97E-04", {"," -> ".", "E" -> "*^"}]]];

Your result is -1.97 * Euler's Number - 4.

Have Fun,
Peter





  • Prev by Date: Re: Margins in DensityGraphics[] et al.
  • Next by Date: RE: Severe ToExpression Fault?
  • Previous by thread: Severe ToExpression Fault?
  • Next by thread: Re: Severe ToExpression Fault?