MathGroup Archive 1996

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

Search the Archive

Re: how to read real numbers in 1.0000e+00 notation


In article <4ojegb$78s at dragonfly.wolfram.com> fedort at elmo.Princeton.EDU  
(Fedor B. Trintchouk) writes:
> 
> I have to read into mathematica ASCII data files containing floating
> point numbers in the notation 
> that uses the character "e" to separate mantissa and exponent. Is there  
a
> mathematica function that converts this into mathematica's proper
> representation, or do I have to use sed or something similar to
> replace e's by something like "*10^" ?  
> 
> Thank you.
> -- 
> --
> Fedor Trintchouk                        (609) 258-4745 (office/voice)
> Princeton University                    (609) 258-1089 (lab)
> fedort at princeton.edu                    (609) 258-1139 (fax)
> 
>

The Number format in Read and ReadList can read number in "e" notation.

In[1]:= !!datafile
1.73e+8  2.75e+7  -16.9e-11

In[1]:= ReadList["datafile", Number]

                8         7          -10
Out[1]= {1.73 10 , 2.75 10 , -1.69 10   }

Also, if you think you need it, a sed script sci2mma is available
on MathSource (item 0206-345: sci2mma -- A Filter to Convert Data
in Scientific Notation Format to Mathematica Input Format).

Or the converter could easily be written in Mathematica rather
than sed, in case you need it on a machine that doesn't have sed.

Dave Withoff
Research and Development
Wolfram Research

==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Series problem
  • Next by Date: Re: how to read real numbers in 1.0000e+00 notation
  • Previous by thread: how to read real numbers in 1.0000e+00 notation
  • Next by thread: Re: how to read real numbers in 1.0000e+00 notation