Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
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 exploiting the Monastery: (5)
As of 2014-09-21 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (166 votes), past polls