Skip to content

Commit

Permalink
Implement Rational.isNaN
Browse files Browse the repository at this point in the history
Currently we use Real.isNaN that always gives False, however a Rat
can be a NaN when both its numerator and denominator are zeroes.
  • Loading branch information
zoffixznet committed Dec 31, 2016
1 parent 73182d4 commit 7434a8f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/core/Rational.pm
Expand Up @@ -65,8 +65,12 @@ my role Rational[::NuT, ::DeT] does Real {
}

method Int() { self.truncate }

method Bridge() { self.Num }
method isNaN {
nqp::p6bool(
nqp::isfalse(self.numerator) && nqp::isfalse(self.denominator)
)
}

multi method Str(::?CLASS:D:) {
if nqp::istype($!numerator,Int) {
Expand Down

0 comments on commit 7434a8f

Please sign in to comment.