Increase coverage of reciprocal
@@ -371,6 +371,16 @@ public class ComplexTest {
Assertions.assertTrue(NAN.reciprocal().isNaN());
}
+ @Test
+ public void testReciprocalMax() {
+ // This hits the edge case in reciprocal() for when q != 0 but scale == 0
+ final double smaller = Math.nextDown(Double.MAX_VALUE);
+ Complex z = Complex.ofCartesian(smaller, Double.MAX_VALUE);
+ Assertions.assertEquals(Complex.ofCartesian(0.0, -0.0), z.reciprocal());
+ z = Complex.ofCartesian(Double.MAX_VALUE, smaller);
+ Assertions.assertEquals(Complex.ofCartesian(0.0, -0.0), z.reciprocal());
+ }
+
@Test
public void testMultiply() {
final Complex x = Complex.ofCartesian(3.0, 4.0);
