Non-decimal radices/Convert: Difference between revisions

Content added Content deleted
(Lua: fix case of n = 0)
(Perl: simplify and fix case of arg $n = 0)
Line 2,638: Line 2,638:
my($n,$b) = @_;
my($n,$b) = @_;
my $s = "";
my $s = "";
while ($n) {
do {
$s .= ('0'..'9','a'..'z')[$n % $b];
$s = ('0'..'9','a'..'z')[$n % $b] . $s
$n = int($n/$b);
} while $n = int($n / $b);
}
$s
scalar(reverse($s));
}
}
sub base_from {
sub base_from {