File tree 2 files changed +20
-2
lines changed
2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,7 @@ fn cosh64(z: Complex(f64)) Complex(f64) {
123
123
}
124
124
// x >= 1455: result always overflows
125
125
else {
126
- const h = 0x1p1023 ;
126
+ const h = 0x1p1023 * x ;
127
127
return Complex (f64 ).init (h * h * @cos (y ), h * @sin (y ));
128
128
}
129
129
}
@@ -170,3 +170,12 @@ test cosh64 {
170
170
try testing .expectApproxEqAbs (-73.46729221264526 , c .re , epsilon );
171
171
try testing .expectApproxEqAbs (10.471557674805572 , c .im , epsilon );
172
172
}
173
+
174
+ test "cosh64 musl" {
175
+ const epsilon = math .floatEps (f64 );
176
+ const a = Complex (f64 ).init (7.44648873421389e17 , 1.6008058402057622e19 );
177
+ const c = cosh (a );
178
+
179
+ try testing .expectApproxEqAbs (std .math .inf (f64 ), c .re , epsilon );
180
+ try testing .expectApproxEqAbs (std .math .inf (f64 ), c .im , epsilon );
181
+ }
Original file line number Diff line number Diff line change @@ -70,7 +70,7 @@ fn tanh64(z: Complex(f64)) Complex(f64) {
70
70
const ix = hx & 0x7fffffff ;
71
71
72
72
if (ix >= 0x7ff00000 ) {
73
- if ((ix & 0x7fffff ) | lx != 0 ) {
73
+ if ((ix & 0xfffff ) | lx != 0 ) {
74
74
const r = if (y == 0 ) y else x * y ;
75
75
return Complex (f64 ).init (x , r );
76
76
}
@@ -118,3 +118,12 @@ test tanh64 {
118
118
try testing .expectApproxEqAbs (0.9999128201513536 , c .re , epsilon );
119
119
try testing .expectApproxEqAbs (-0.00002536867620767604 , c .im , epsilon );
120
120
}
121
+
122
+ test "tanh64 musl" {
123
+ const epsilon = math .floatEps (f64 );
124
+ const a = Complex (f64 ).init (std .math .inf (f64 ), std .math .inf (f64 ));
125
+ const c = tanh (a );
126
+
127
+ try testing .expectApproxEqAbs (1 , c .re , epsilon );
128
+ try testing .expectApproxEqAbs (0 , c .im , epsilon );
129
+ }
You can’t perform that action at this time.
0 commit comments