Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Opposite of strtol?

by ysth (Canon)
on Jun 21, 2009 at 19:00 UTC ( #773404=note: print w/replies, xml ) Need Help??


in reply to Opposite of strtol?

Not a one-liner, but fairly straightforward (untested):
sub ltostr { my ($num, $base) = @_; Carp::croak("Invalid base $base") if $base < 2 || $base > 36; my $neg = $num < 0; $num = -$num if $neg; my $str = ''; do { $str = ( '0'..'9', 'a'..'z' )[ $num % $base ] . $str; $num = int( $num / $base ); } while $num; $str = "-$str" if $neg; return $str; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://773404]
help
Chatterbox?
[Discipulus]: my whishlist include more "elements" anyway

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2017-02-24 09:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (353 votes). Check out past polls.