Skip to content

Conversation

tsardaryanCamenAI
Copy link
Contributor

@tsardaryanCamenAI tsardaryanCamenAI commented May 11, 2023

Prerequisites

  • I have written a descriptive pull-request title
  • I have verified that there are no overlapping pull-requests open
  • I have verified that I am following the existing coding patterns and practice as demonstrated in the repository. These follow strict Stylecop rules 👮.
  • I have provided test coverage for my change (where applicable)

Description

In cases, when you're trying to create Rational.FromDouble(0) it generates an invalid Rational item.

@CLAassistant
Copy link

CLAassistant commented May 11, 2023

CLA assistant check
All committers have signed the CLA.

this.Numerator = (uint)rational.Numerator;
this.Denominator = (uint)rational.Denominator;

if(this.Numerator == 0 && this.Denominator == 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there's an issue here it will have to be fixed in LongRational

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want to update GPS location of ExifInformation, it accepts Retional[]. That's why I suggest this change. Anyway if you are creating Rational.FromDouble(0) Denominator shouldn't be 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right, the problem is deeper on line 206 of LongRational.cs it should be

return new LongRational(0, 1);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the correct fix. Can you also add some unit tests for this to make sure this stays fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, sure will do that and will push all as a different pull request. You can close this one.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to open a new PR. That’s just confusing. Push to this one please.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And you can also use a force push to update this PR with a new set of commits.

double df = numerator / (double)denominator;
double epsilon = bestPrecision ? double.Epsilon : .000001;

if(val < epsilon) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't the fix be the following inserted at 149?

if (value == 0)
{
    return new LongRational(0, 1);
}

@JimBobSquarePants JimBobSquarePants added this to the v3.1.0 milestone May 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants