Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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; }


Comment on Re: Opposite of strtol?
Download Code

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 perusing the Monastery: (9)
As of 2015-07-01 21:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (22 votes), past polls