Skip to content

Commit 30f6b95

Browse files
committed
use double's tiny in ld
1 parent ff69b8e commit 30f6b95

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

quaddtype/tests/test_quaddtype.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5477,10 +5477,19 @@ def test_same_value_cast_floats_within_range(self, dtype):
54775477
passing_values = [
54785478
1.0, -1.0, 0.5, -0.5, 0.25, -0.25,
54795479
2.0, 4.0, 8.0, # powers of 2
5480-
info.tiny, # min positive normal
54815480
2 ** info.nmant, # largest consecutive integer
54825481
]
54835482

5483+
# For longdouble on x86-64, info.tiny can be ~3.36e-4932, which is outside
5484+
# the double range (~2.2e-308). Since SLEEF backend converts quad <-> longdouble
5485+
# via double (Sleef_cast_to/from_doubleq1), values outside double's range
5486+
# cannot roundtrip correctly. Use double's tiny for longdouble in this case.
5487+
double_info = np.finfo(np.float64)
5488+
if dtype == np.longdouble and info.tiny < double_info.tiny:
5489+
passing_values.append(double_info.tiny)
5490+
else:
5491+
passing_values.append(info.tiny)
5492+
54845493
for val in passing_values:
54855494
# Ensure the value is representable in the target dtype first
54865495
target_val = dtype(val)

0 commit comments

Comments
 (0)