Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Add exp(Numeric, Numeric). Fix infix:<**>(Int, Int) to handle negativ…
…e powers properly.
  • Loading branch information
colomon committed Jul 16, 2011
1 parent afc5299 commit 7940ef2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/Int.pm
Expand Up @@ -84,7 +84,11 @@ multi infix:<%>(Int \$a, Int \$b) {
}

multi infix:<**>(Int \$a, Int \$b) {
nqp::p6box_i(nqp::pow_n(nqp::unbox_i($a), nqp::unbox_i($b)))
if $b >= 0 {
nqp::p6box_i(nqp::pow_n(nqp::unbox_i($a), nqp::unbox_i($b)))
} else {
nqp::p6box_n(nqp::pow_n(nqp::unbox_i($a), nqp::unbox_i($b)))
}
}

multi infix:<lcm>(Int \$a, Int \$b) {
Expand Down
1 change: 1 addition & 0 deletions src/core/Numeric.pm
Expand Up @@ -47,6 +47,7 @@ multi sub log10(Cool $x) { $x.Numeric.log(10e0) }

proto sub exp(|$) {*}
multi sub exp(Numeric $x) { $x.exp }
multi sub exp(Numeric $x, Numeric $base) { $x.exp($base) }

proto sub sin(|$) {*}
multi sub sin(Numeric \$x) { $x.sin }
Expand Down

0 comments on commit 7940ef2

Please sign in to comment.