Skip to content

Commit d777529

Browse files
committed
it was dragon4 all along
1 parent 96e60fa commit d777529

File tree

2 files changed

+25
-7
lines changed

2 files changed

+25
-7
lines changed

quaddtype/numpy_quaddtype/src/dragon4.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1885,8 +1885,13 @@ Dragon4_PrintFloat_Sleef_quad(Sleef_quad *value, Dragon4_Options *opt)
18851885
union {
18861886
Sleef_quad q;
18871887
struct {
1888+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
1889+
npy_uint64 hi;
1890+
npy_uint64 lo;
1891+
#else
18881892
npy_uint64 lo;
18891893
npy_uint64 hi;
1894+
#endif
18901895
} i;
18911896
} u;
18921897
u.q = *value;

quaddtype/numpy_quaddtype/src/quaddtype_main.c

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,26 @@ py_is_longdouble_128(PyObject *self, PyObject *args)
3131
}
3232
}
3333

34+
#ifdef SLEEF_QUAD_C
35+
static const Sleef_quad SMALLEST_SUBNORMAL_VALUE = SLEEF_QUAD_DENORM_MIN;
36+
#else
37+
static const union {
38+
struct {
3439
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
35-
#warning "Big-endian platform detected"
40+
uint64_t h, l;
3641
#else
37-
#warning "Little Endian"
42+
uint64_t l, h;
43+
#endif
44+
} parts;
45+
Sleef_quad value;
46+
} smallest_subnormal_const = {.parts = {
47+
#if defined(__BYTE_ORDER__) && (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
48+
.h = 0x0000000000000000ULL, .l = 0x0000000000000001ULL
49+
#else
50+
.l = 0x0000000000000001ULL, .h = 0x0000000000000000ULL
51+
#endif
52+
}};
53+
#define SMALLEST_SUBNORMAL_VALUE (smallest_subnormal_const.value)
3854
#endif
3955

4056
static PyObject *
@@ -78,11 +94,8 @@ get_sleef_constant(PyObject *self, PyObject *args)
7894
result->value.sleef_value = SLEEF_QUAD_MIN;
7995
}
8096
else if (strcmp(constant_name, "smallest_subnormal") == 0) {
81-
#ifdef SLEEF_QUAD_C
82-
result->value.sleef_value = SLEEF_QUAD_DENORM_MIN;
83-
#else
84-
result->value.sleef_value = sleef_q(+0x0000000000000LL, 0x0000000000000001ULL, -16383);
85-
#endif
97+
// or just use sleef_q(+0x0000000000000LL, 0x0000000000000001ULL, -16383);
98+
result->value.sleef_value = SMALLEST_SUBNORMAL_VALUE;
8699
}
87100
else if (strcmp(constant_name, "bits") == 0) {
88101
Py_DECREF(result);

0 commit comments

Comments
 (0)