+converters

This commit is contained in:
Thomas von Dein
2020-03-25 20:48:33 +01:00
parent d77455140a
commit 93ca7421ed

24
rpnc
View File

@@ -12,7 +12,7 @@ my $term = Term::ReadLine->new('rpn calc');
my $debug = 0; my $debug = 0;
my $showstack = 1; my $showstack = 1;
my $tty = 1; my $tty = 1;
my $VERSION = '1.06'; my $VERSION = '1.07';
my $sub = 0; my $sub = 0;
my $maxstack = 10; my $maxstack = 10;
my $maxreg = 5; my $maxreg = 5;
@@ -171,7 +171,21 @@ my %func = (
'a' => sub { 'a' => sub {
# average # average
return "(" . join(' + ', @_) . ") / " . scalar @_; return "(" . join(' + ', @_) . ") / " . scalar @_;
} },
# converters:
# gallons to liters
'tl' => sub { return $_[0] * 3.785 },
# yards to meters
'tm' => sub { return $_[0] * 91.44 },
# miles to kilometers
'tk' => sub { return $_[0] * 1.609 },
# inches to cm
'tc' => sub { return $_[0] * 2.54 },
# to 'bytes
'tkb' => sub { return $_[0] / 1000 },
'tmb' => sub { return $_[0] / 1000 / 1000},
'tgb' => sub { return $_[0] / 1000 / 1000 / 1000 },
'ttb' => sub { return $_[0] / 1000 / 1000 / 1000 / 1000 },
); );
# math constants, always upper case letters, usable via eval{} # math constants, always upper case letters, usable via eval{}
@@ -512,6 +526,12 @@ Register Management: x bitwise XOR
rcx clear X (last register element) m median rcx clear X (last register element) m median
rc clear register a average rc clear register a average
Converters:
tl gallons => liters tkb bytes => kb
tk miles => kilometers tmb bytes => mb
tm yards => meters tgb bytes => gb
tc inches => centimeters ttb bytes => tb
Various Commands Constants: PI V2 V3 Various Commands Constants: PI V2 V3
u undo last operation u undo last operation
h show history of past operations Using register: h show history of past operations Using register: