Re: Is there ToNumber?
- To: mathgroup at smc.vnet.net
- Subject: [mg119614] Re: Is there ToNumber?
- From: "Hans Michel" <hmichel at cox.net>
- Date: Mon, 13 Jun 2011 05:18:05 -0400 (EDT)
- References: <isnllk$n7b$1@smc.vnet.net> <201106090945.FAA06238@smc.vnet.net> <201106120907.FAA11484@smc.vnet.net>
In[1]:= ImportString["1e3", {"List"}]
Out[1]= {1000.}
It seems that some how only the draft version of my email went out.
I was trying to point to using ImportString.
And reaffirming my stance that more emphasis should be place what I call a
gateway function to mathematica "Import".
Hans
-----Original Message-----
From: ADL [mailto:alberto.dilullo at tiscali.it]
Sent: Sunday, June 12, 2011 4:07 AM
To: mathgroup at smc.vnet.net
Subject: [mg119614] Re: Is there ToNumber?
On 11 Giu, 12:52, "Dr. Peter Klamser" <klam... at googlemail.com> wrote:
> ... ToExpression["1+1"]
>
> One Hint: If you know a function in Mathematica like "ToString", you
> mentioned in your email, look in the help system in the section "see
> also", there you find ToExpression["1+1"].
>
> Kind regards
>
> Peter
>
> Am 11.06.2011 09:59, schrieb Ted Sariyski:
>
> > Hi,
> > Is there a built-in function which returns the numeric value of a string
> > (like ToString but inverse). Currently I use mine function toNumber:
>
> > ch = StringToStream[timeStr];
> > timeNum = Read[ch, Number];
> > Close[ch];
>
> > but I suspect there is easier way.
> > Thanks in advance,
> > --Ted
>
> --
> Mit freundlichen Gr en
>
> Uta& Peter Klamser
The request is less trivial than ToExpression["1+1"] since, for
example, typical number format cannot be read into Mathematica without
the rather involved trick reported by Ted Sariyski. As an example,
ToExpression["1e3"]
==> e3
ch = StringToStream["1e3"];
timeNum = Read[ch, Number];
Close[ch];
timeNum
==> 1000
I feel this complication as rather unfortunate, unless I am also
missing a simpler way to read in numbers.
ADL
- References:
- Re: How show axes labels with AxesOrigin->{0,0,0} in 3D?
- From: Peter Breitfeld <phbrf@t-online.de>
- Re: Is there ToNumber?
- From: ADL <alberto.dilullo@tiscali.it>
- Re: How show axes labels with AxesOrigin->{0,0,0} in 3D?