Skip to content

Commit 8114dbc

Browse files
committed
Fix cross-platform negative value conversion for unsigned integer types
1 parent 2c4b9f9 commit 8114dbc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

ext/numo/narray/numo/types/xint_macro.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33

44
#define m_extract(x) m_data_to_num(*(dtype*)(x))
55

6-
#define m_from_double(x) (x)
7-
#define m_from_real(x) (x)
6+
/* Handle negative values consistently across platforms for unsigned integer types */
7+
#define m_from_double(x) ((x) < 0 ? (dtype)((long long)(x)) : (dtype)(x))
8+
#define m_from_real(x) ((x) < 0 ? (dtype)((long long)(x)) : (dtype)(x))
89
#define m_from_sint(x) (x)
910
#define m_from_int32(x) (x)
1011
#define m_from_int64(x) (x)

0 commit comments

Comments
 (0)