Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2016-10-01 15:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Extraterrestrials haven't visited the Earth yet because:







    Results (579 votes). Check out past polls.