summaryrefslogtreecommitdiffstats
path: root/bin/base26
blob: 1a24921c14e8cc7245363e7d548d042b06e2cb4a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use Math::BigInt;

$err = 0;

$a = ord('A');
foreach $n (@ARGV) {
    $s = '';
    $x = Math::BigInt->new($n);
    if ( $x->bcmp(0) <= 0 ) {
	print "\n";
	$err = 1;
	next;
    }
    while ( !$x->is_zero() ) {
	$x->bdec();
	($q, $r) = $x->bdiv(26);
	$s = chr($a + $r->numify()) . $s;
    }

    print $n, ' ', $s, "\n";
}

exit $err;