hex and oct numbers

This commit is contained in:
Peter J. Holzer 2012-11-29 17:09:20 +01:00
parent ac9719ad57
commit 9d590f521c
1 changed files with 6 additions and 0 deletions

6
rpn
View File

@ -41,6 +41,12 @@ while (<>) {
} elsif (m{^ld$}) { } elsif (m{^ld$}) {
my $x = pop @stack; my $x = pop @stack;
push @stack, log($x) / log(2); push @stack, log($x) / log(2);
} elsif (m{^0x[0-9a-fA-F]+$}) {
no warnings 'portable';
push @stack, hex($_);
} elsif (m{^0[0-7]+$}) {
no warnings 'portable';
push @stack, oct($_);
} else { } else {
push @stack, $_; push @stack, $_;
} }