Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 5f9884c

Browse files
committed
Merge pull request #2284 from stephentoub/complex_verify
Add checks for infinity to Complex.Pow verification
2 parents 470f290 + 23c662f commit 5f9884c

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/System.Runtime.Numerics/tests/Complex/ComplexTestSupport.cs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,21 @@ public static double GetRandomPhaseValue(bool fIsNegative)
159159

160160
public static bool IsDiffTolerable(double d1, double d2)
161161
{
162-
double diffRatio = (d1 - d2) / d1;
163-
diffRatio *= Math.Pow(10, 6);
164-
diffRatio = Math.Abs(diffRatio);
165-
return (diffRatio < 1);
162+
if (double.IsInfinity(d1))
163+
{
164+
return d1 == (d2 * 10);
165+
}
166+
else if (double.IsInfinity(d2))
167+
{
168+
return d2 == (d1 * 10);
169+
}
170+
else
171+
{
172+
double diffRatio = (d1 - d2) / d1;
173+
diffRatio *= Math.Pow(10, 6);
174+
diffRatio = Math.Abs(diffRatio);
175+
return (diffRatio < 1);
176+
}
166177
}
167178

168179
public static void VerifyRealImaginaryProperties(Complex complex, double real, double imaginary, string message)

0 commit comments

Comments
 (0)