aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/fix-incorrect-results-for-catanf-and-catanl-with-som.patch
blob: 4aa3487bb2b7834798837187b4bd72e6df65bd7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
From 11020620813b828917bc31b4636d8a142f7a564a Mon Sep 17 00:00:00 2001
From: Rich Felker <dalias@aerifal.cx>
Date: Wed, 5 Feb 2020 09:40:11 -0500
Subject: [PATCH] fix incorrect results for catanf and catanl with some inputs

catan was fixed in 10e4bd3780050e75b72aac5d85c31816419bb17d but the
same bug in catanf and catanl was overlooked. the patch is completely
analogous.
---
 src/complex/catanf.c | 14 +-------------
 src/complex/catanl.c | 14 +-------------
 2 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/src/complex/catanf.c b/src/complex/catanf.c
index e10d9c09..ef3907a5 100644
--- a/src/complex/catanf.c
+++ b/src/complex/catanf.c
@@ -87,29 +87,17 @@ float complex catanf(float complex z)
 	x = crealf(z);
 	y = cimagf(z);
 
-	if ((x == 0.0f) && (y > 1.0f))
-		goto ovrf;
-
 	x2 = x * x;
 	a = 1.0f - x2 - (y * y);
-	if (a == 0.0f)
-		goto ovrf;
 
 	t = 0.5f * atan2f(2.0f * x, a);
 	w = _redupif(t);
 
 	t = y - 1.0f;
 	a = x2 + (t * t);
-	if (a == 0.0f)
-		goto ovrf;
 
 	t = y + 1.0f;
 	a = (x2 + (t * t))/a;
-	w = w + (0.25f * logf (a)) * I;
-	return w;
-
-ovrf:
-	// FIXME
-	w = MAXNUMF + MAXNUMF * I;
+	w = CMPLXF(w, 0.25f * logf(a));
 	return w;
 }
diff --git a/src/complex/catanl.c b/src/complex/catanl.c
index a9fc02db..e62526c0 100644
--- a/src/complex/catanl.c
+++ b/src/complex/catanl.c
@@ -97,30 +97,18 @@ long double complex catanl(long double complex z)
 	x = creall(z);
 	y = cimagl(z);
 
-	if ((x == 0.0L) && (y > 1.0L))
-		goto ovrf;
-
 	x2 = x * x;
 	a = 1.0L - x2 - (y * y);
-	if (a == 0.0L)
-		goto ovrf;
 
 	t = atan2l(2.0L * x, a) * 0.5L;
 	w = redupil(t);
 
 	t = y - 1.0L;
 	a = x2 + (t * t);
-	if (a == 0.0L)
-		goto ovrf;
 
 	t = y + 1.0L;
 	a = (x2 + (t * t)) / a;
-	w = w + (0.25L * logl(a)) * I;
-	return w;
-
-ovrf:
-	// FIXME
-	w = LDBL_MAX + LDBL_MAX * I;
+	w = CMPLXF(w, 0.25L * logl(a));
 	return w;
 }
 #endif
-- 
2.24.1