MathGroup Archive 2007

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

Search the Archive

Re: String to number


I would do it like this:

Fold[(10 #1 + #2) &, 0, ToExpression[Characters[YOURSTRINGHERE]]]

For example,
Fold[(10 #1 + #2) &, 0, ToExpression[Characters["123"]]]

  -> 123

Michael




On 2/6/07, Jos=E9 Carlos Santos <jcsantos at fc.up.pt> wrote:
> Hi all:
>
> The ToString command generates a string from an expression. Is there a
> similar command which generates numbers from strings? What I mean by
> this is: is there a command (let's call it ToNumber) such that
>
> ToNumber["12"]
>
> generates the number 12?
>
> Best regards,
>
> Jose Carlos Santos
>
>


  • Prev by Date: Passing a list as seperate parameters?
  • Next by Date: Re: String to number
  • Previous by thread: RE: String to number
  • Next by thread: Re: String to number