in reply to Math::Base - arithmetics with baseX integers (updated)
This is a neat idea, but encode spins forever when $num is negative and returns an empty string when it's zero. You could do this:
But '-' is in the @chars array.my $val = abs($num); do { push @ret, $chars[$val % $base]; $val = int($val / $base); } while $val; push @ret, '-' if $num < 0;
In Section
Cool Uses for Perl