Possibly fixed Fraction division-by-zero exception? (can't reproduce)

This commit is contained in:
N00MKRAD
2021-04-03 00:17:29 +02:00
parent 5556b5a5c7
commit ada9aefab1

View File

@@ -111,6 +111,8 @@ namespace Flowframes.Data
//Reduce the fraction to lowest terms //Reduce the fraction to lowest terms
Fraction modifiedFraction = this; Fraction modifiedFraction = this;
try
{
//While the numerator and denominator share a greatest common denominator, //While the numerator and denominator share a greatest common denominator,
//keep dividing both by it //keep dividing both by it
int gcd = 0; int gcd = 0;
@@ -126,6 +128,11 @@ namespace Flowframes.Data
modifiedFraction.Numerator = -this.Numerator; modifiedFraction.Numerator = -this.Numerator;
modifiedFraction.Denominator = -this.Denominator; modifiedFraction.Denominator = -this.Denominator;
} }
}
catch (Exception e)
{
Logger.Log($"Failed to reduce fraction ({modifiedFraction}): {e.Message}", true);
}
return modifiedFraction; return modifiedFraction;
} }