Skip to content

Commit

Permalink
Fix incorrect underflow detection in infix:<**>
Browse files Browse the repository at this point in the history
Introed in previous commit[^1].
Since we negate the power, we'd get an Inf on too large
power, not 0e0.

[1] d1729da
  • Loading branch information
zoffixznet committed Jul 31, 2018
1 parent d1729da commit f9963bb
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/core/Rat.pm6
Expand Up @@ -194,14 +194,13 @@ multi sub infix:<**>(Rational:D \a, Int:D \b) {
nqp::istype(($de := nqp::pow_I(a.denominator, nqp::decont(b), Num, Int)), Num),
Failure.new(X::Numeric::Overflow.new),
RAKUDO_INTERNAL_DIVIDE_NUMBERS_NO_NORMALIZE $nu, $de, a, b)),
nqp::if( # if we got 0 as result, but shouldn't have
nqp::isfalse($nu := nqp::pow_I(a.numerator, nqp::neg_I(nqp::decont(b), Int), Num, Int))
&& a.numerator,
nqp::if( # if we got Inf
nqp::istype(($nu := nqp::pow_I(a.numerator,
nqp::neg_I(nqp::decont(b), Int), Num, Int)), Num),
Failure.new(X::Numeric::Underflow.new),
nqp::if( # if we got 0 as result, but shouldn't have
nqp::isfalse($de := nqp::pow_I(a.denominator,
nqp::neg_I(nqp::decont(b), Int), Num, Int))
&& a.denominator,
nqp::if( # if we got Inf
nqp::istype(($de := nqp::pow_I(a.denominator,
nqp::neg_I(nqp::decont(b), Int), Num, Int)), Num),
Failure.new(X::Numeric::Underflow.new),
RAKUDO_INTERNAL_DIVIDE_NUMBERS_NO_NORMALIZE $de, $nu, a, b)))
}
Expand Down

0 comments on commit f9963bb

Please sign in to comment.