logo       

Re: string conversion, format functions: msg#00339

lang.erlang.general

Subject: Re: string conversion, format functions

Strange, but they are in erlang, not strings:

list_to_integer/1
integer_to_list/1

since a string is a list, they work quite well. :)


HP Wei <hp@xxxxxxxxxx> wrote:
> I have a string "123" and want to convert it to an integer
> or float, and vice versa.
>
> In python, I go to the string module and
> there are string.atoi(), string.atof(), and str(number).
> So, by habit, I went to string module doc in Erlang
> I could not find the counterparts of these functions. Where are they ?
>
> -------------------------
> B = 3.
>
> I want to form a string "0003".
> ** Can io:format generate such a printout ?
> ** Can it be redirected to a string ?
> ** If not, how do folks in Erlang world do this padding?
>
> thanks,
> hp
>

--
Shawn.

/*
* [...] Note that 120 sec is defined in the protocol as the maximum
* possible RTT. I guess we'll have to use something other than TCP
* to talk to the University of Mars.
* PAWS allows us longer timeouts and large windows, so once implemented
* ftp to mars will work nicely.
*/
-- from /usr/src/linux/net/inet/tcp.c, concerning RTT [round trip time]



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise