[Date Index] [Thread Index] [Author Index]
Re: I want to read numbers written in E-format.
Peter Whaite writes: > I have programs that write Mma expressions to a file. I bring this file into > Mma using Get. Unfortunately there are numbers in the file which are > sometimes in e-format, so e.g. 1.234e+456 gets parsed as 456 + 1.234*e. > ReadList can handle e-format numbers but I can't use it. > > I can do something like... [scheme for altering the semantics of plus deleted.] The proper way to do this is probably to write something involving $PreRead to turn xxxe+yy into xxx*10^yy and xxxe-yy into xxx*10^-yy. But another approach is to just transform the file first. I'm sure the problem is easy in sed, but if you are using emacs, my math-mode for Gnu Emacs already has a function to do this. Just get the file, set "mark" and "point" and the beginning and end of the file, then type ESC x math-transform-floats-in-region RET, and it will be done. You can get math.el, which implements math-mode, from MathSource, or by ftp from otter.stanford.edu, get mma/Utilities/math.el.Z. -- David Jacobson