Add functions sin, cos, tan, exp and constant e
This commit is contained in:
parent
0f0027d73c
commit
ada378e290
14
rpn
14
rpn
|
@ -43,6 +43,20 @@ 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{^sin$}) {
|
||||||
|
my $x = pop @stack;
|
||||||
|
push @stack, sin($x);
|
||||||
|
} elsif (m{^cos$}) {
|
||||||
|
my $x = pop @stack;
|
||||||
|
push @stack, cos($x);
|
||||||
|
} elsif (m{^tan$}) {
|
||||||
|
my $x = pop @stack;
|
||||||
|
push @stack, tan($x);
|
||||||
|
} elsif (m{^e$}) {
|
||||||
|
push @stack, exp(1);
|
||||||
|
} elsif (m{^exp$}) {
|
||||||
|
my $x = pop @stack;
|
||||||
|
push @stack, exp($x);
|
||||||
} elsif (m{^0x[0-9a-fA-F]+$}) {
|
} elsif (m{^0x[0-9a-fA-F]+$}) {
|
||||||
no warnings 'portable';
|
no warnings 'portable';
|
||||||
push @stack, hex($_);
|
push @stack, hex($_);
|
||||||
|
|
Loading…
Reference in New Issue