Skip to content

Commit

Permalink
- Extended the Number exp(n) method to accept an additional argument.
Browse files Browse the repository at this point in the history
When two arguments are given, it does floating-point exponentiation: b^x.

Example:

	say exp(2, 10)		#=> 1024
  • Loading branch information
trizen committed May 4, 2022
1 parent 908ce38 commit 30b1002
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Sidef/Types/Number/Number.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3488,7 +3488,13 @@ package Sidef::Types::Number::Number {
}

sub exp {
my ($x) = @_;
my ($x, $y) = @_;

if (defined($y)) {
_valid(\$y);
return bless \__pow__(_any2mpfr_mpc($$x), _any2mpfr_mpc($$y));
}

bless \__exp__(_any2mpfr_mpc($$x));
}

Expand Down
3 changes: 3 additions & 0 deletions lib/Sidef/Types/Number/Number.pod
Original file line number Diff line number Diff line change
Expand Up @@ -2282,9 +2282,12 @@ Returns back C<x>.
=head2 exp

exp(x)
exp(b, x)

Exponential function: C<e^x>.

When two arguments are given, it does floating-point exponentiation: C<b^x>.

=cut

=head2 exp10
Expand Down

0 comments on commit 30b1002

Please sign in to comment.