We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents dfe4bdd + 68530cd commit 156edadCopy full SHA for 156edad
2 files changed
src/include/ops.hpp
@@ -629,6 +629,11 @@ quad_mod(const Sleef_quad *a, const Sleef_quad *b)
629
630
// finite % inf
631
if (quad_isfinite(a) && quad_isinf(b)) {
632
+ // 0 % inf
633
+ if (Sleef_icmpeqq1(*a, QUAD_PRECISION_ZERO)) {
634
+ return Sleef_copysignq1(*a, *b);
635
+ }
636
+
637
int sign_a = quad_signbit(a);
638
int sign_b = quad_signbit(b);
639
@@ -1241,6 +1246,10 @@ ld_mod(const long double *a, const long double *b)
1241
1246
return NAN;
1242
1247
1243
1248
if (isfinite(*a) && isinf(*b)) {
1249
1250
+ if (*a == 0.0L) {
1251
+ return copysignl(*a, *b);
1252
1244
1253
int sign_a = signbit(*a);
1245
1254
int sign_b = signbit(*b);
1255
return (sign_a == sign_b) ? *a : *b;
tests/test_quaddtype.py
@@ -2629,7 +2629,8 @@ def test_array_operations():
2629
# Finite % infinity cases
2630
(5.0, float('inf')), (-5.0, float('inf')),
2631
(5.0, float('-inf')), (-5.0, float('-inf')),
2632
- (0.0, float('inf')), (-0.0, float('-inf')),
+ (0.0, float('inf')), (-0.0, float('inf')),
2633
+ (0.0, float('-inf')), (-0.0, float('-inf')),
2634
2635
# NaN cases (should return NaN)
2636
(float('nan'), 3.0), (3.0, float('nan')), (float('nan'), float('nan')),
@@ -2674,6 +2675,7 @@ def test_mod(a, b, backend, op):
2674
2675
if numpy_result == 0.0:
2676
numpy_sign = np.signbit(numpy_result)
2677
quad_sign = np.signbit(quad_result)
2678
+ assert quad_result == 0, f"Zero mismatch for {a} % {b}: numpy={numpy_result}, quad={quad_result}"
2679
assert numpy_sign == quad_sign, f"Zero sign mismatch for {a} % {b}: numpy={numpy_sign}, quad={quad_sign}"
2680
2681
# Check that non-zero results have correct sign relative to divisor
0 commit comments