Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
better undef/overflow on Rat ** Int
  • Loading branch information
TimToady committed Dec 4, 2015
1 parent 6779524 commit 5b8c080
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/core/Rat.pm
Expand Up @@ -204,16 +204,15 @@ multi sub infix:<%>(Rational \a, Rational \b) {
multi sub infix:<**>(Rational \a, Int \b) {
b >= 0
?? DIVIDE_NUMBERS
a.numerator ** b,
a.denominator ** b,
(a.numerator ** b // fail (a.numerator.abs > a.denominator ?? X::Numeric::Overflow !! X::Numeric::Underflow).new),
a.denominator ** b, # we presume it likely already blew up on the numerator
a,
b
!! DIVIDE_NUMBERS
a.denominator ** -b,
(a.numerator ** -b // fail (a.numerator.abs < a.denominator ?? X::Numeric::Overflow !! X::Numeric::Underflow).new),
a.numerator ** -b,
a,
b
or a == 0.0 ?? 0.0 !! fail X::Numeric::Overflow.new; # can this happen?
}

multi sub infix:<==>(Rational:D \a, Rational:D \b) {
Expand Down

0 comments on commit 5b8c080

Please sign in to comment.