Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #6837

Re: how to get string in sci. notation to a number?

From "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: how to get string in sci. notation to a number?
Date 2011-11-30 08:25 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jb4pai$gsh$1@smc.vnet.net> (permalink)
References <jb2hum$5e0$1@smc.vnet.net> <jb2kp7$6j4$1@smc.vnet.net>

Show all headers | View raw


On Tue, 29 Nov 2011 12:56:07 -0000, Oleksandr Rasputinov  
<oleksandr_rasputinov@hmamail.com> wrote:

>
> In place of "e", Mathematica uses "*^". When reading output from a Python
> program into Mathematica for analysis, I have used StringReplace to
> convert to valid Mathematica syntax followed by ToExpression; this can be
> faster and more convenient than Import in certain cases.

Actually that approach might be convenient here too, and definitely faster  
than ImportString on each element for large tables of values...

ToExpression@Internal`Deflatten[
  (* StringReplace doesn't like nested lists... *)
  StringReplace[Flatten[lst], "e" -> "*^"],
  Dimensions[lst]
]

{{4.99887, 9.56445*10^-6},
  {5.63045, 9.19438*10^-6},
  {6.11328, 8.13417*10^-6}}

Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

how to get string in sci. notation to a number? "1.156" <rob@piovere.com> - 2011-11-29 12:07 +0000
  Re: how to get string in sci. notation to a number? A Retey <awnl@gmx-topmail.de> - 2011-11-29 12:41 +0000
  Re: how to get string in sci. notation to a number? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-29 12:56 +0000
    Re: how to get string in sci. notation to a number? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-11-30 08:25 +0000
  Re: how to get string in sci. notation to a number? Chris Degnen <degnen@cwgsy.net> - 2011-12-01 12:26 +0000
  Re: how to get string in sci. notation to a number? Ralph Dratman <ralph.dratman@gmail.com> - 2011-12-02 12:27 +0000
  Re: how to get string in sci. notation to a number? "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2012-01-09 08:16 +0000

csiph-web