From c19847efedabd5ff38a2c6c4f79f622450a9eb01 Mon Sep 17 00:00:00 2001 From: tdurieux Date: Tue, 7 Mar 2017 13:14:21 +0100 Subject: [PATCH] fixed files form Math #1 --- .../Math/1/org/apache/commons/math3/fraction/BigFraction.java | 3 +++ .../Math/1/org/apache/commons/math3/fraction/Fraction.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/projects/Math/1/org/apache/commons/math3/fraction/BigFraction.java b/projects/Math/1/org/apache/commons/math3/fraction/BigFraction.java index ed4108d..4ca33eb 100644 --- a/projects/Math/1/org/apache/commons/math3/fraction/BigFraction.java +++ b/projects/Math/1/org/apache/commons/math3/fraction/BigFraction.java @@ -303,6 +303,9 @@ private BigFraction(final double value, final double epsilon, if ((p2 > overflow) || (q2 > overflow)) { // in maxDenominator mode, if the last fraction was very close to the actual value // q2 may overflow in the next iteration; in this case return the last one. + if (epsilon == 0.0 && FastMath.abs(q1) < maxDenominator) { + break; + } throw new FractionConversionException(value, p2, q2); } diff --git a/projects/Math/1/org/apache/commons/math3/fraction/Fraction.java b/projects/Math/1/org/apache/commons/math3/fraction/Fraction.java index 8065885..002dae9 100644 --- a/projects/Math/1/org/apache/commons/math3/fraction/Fraction.java +++ b/projects/Math/1/org/apache/commons/math3/fraction/Fraction.java @@ -212,6 +212,9 @@ private Fraction(double value, double epsilon, int maxDenominator, int maxIterat if ((FastMath.abs(p2) > overflow) || (FastMath.abs(q2) > overflow)) { // in maxDenominator mode, if the last fraction was very close to the actual value // q2 may overflow in the next iteration; in this case return the last one. + if (epsilon == 0.0 && FastMath.abs(q1) < maxDenominator) { + break; + } throw new FractionConversionException(value, p2, q2); }