Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inf.Rat == Rational bug #2578

Closed
b2gills opened this issue Jan 1, 2019 · 2 comments
Closed

Inf.Rat == Rational bug #2578

b2gills opened this issue Jan 1, 2019 · 2 comments
Labels
tests needed Issue is generally resolved but tests were not written yet

Comments

@b2gills
Copy link
Contributor

b2gills commented Jan 1, 2019

The Problem

The &infix:<==>(Rational:D \a, Rational:D \b) candidate doesn't handle Inf.Rat properly.

1/0 == 1/3; # True
1/3 == 1/0; # True

Since both Inf.Rat and NaN.Rat have zero for a denominator, the following gets to the code marked with # NaN != NaN.

multi sub infix:<==>(Rational:D \a, Rational:D \b) {
    nqp::hllbool(
      nqp::isfalse(a.denominator) || nqp::isfalse(b.denominator)
        ?? nqp::iseq_I(a.numerator, b.numerator)
          && nqp::istrue(a.numerator) # NaN != NaN
        !! nqp::iseq_I(
            nqp::mul_I(a.numerator, b.denominator, Int),
            nqp::mul_I(b.numerator, a.denominator, Int)))
}
@b2gills b2gills changed the title Rational == Rational bug Inf.Rat == Rational bug Jan 1, 2019
@lizmat
Copy link
Contributor

lizmat commented Jan 2, 2019

Fixed with c11e7e6 .

@lizmat lizmat added the tests needed Issue is generally resolved but tests were not written yet label Jan 2, 2019
@lizmat
Copy link
Contributor

lizmat commented Jan 2, 2019

Tests added with Raku/roast@6feffac83c

@lizmat lizmat closed this as completed Jan 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests needed Issue is generally resolved but tests were not written yet
Projects
None yet
Development

No branches or pull requests

2 participants