RE: Severe ToExpression Fault?
- To: mathgroup at smc.vnet.net
- Subject: [mg42900] RE: [mg42892] Severe ToExpression Fault?
- From: David.Annetts at csiro.au
- Date: Sat, 2 Aug 2003 04:12:25 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Hi Nils, > 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. It's a feature! -9.35502 = -1.97 * E - 4 In the absence of other more eloquent solutions, Read[StringToStream[StringReplace["-1,97E-04", {"," -> "."}]], Number] Should return -0.000197. Regards, Dave. ========================================== Dr. David Annetts EM Modelling Analyst CSIRO DEM Tel: +612 9490 5416 North Ryde Fax: +612 9490 5467 Australia David.Annetts at csiro.au ===========================================