1- // These definitions modified from numarray's Include/numarray/nummacro.h
1+ /*
22
3- // The "64" in this code refers to double precision floating point numbers.
3+ These definitions were inspired by and originally modified from
4+ numarray's Include/numarray/nummacro.h
5+
6+ The "64" below refers to double precision floating point numbers. This
7+ code only works on doubles.
8+
9+ */
410
511#if defined(SIZEOF_VOID_P )
612#if SIZEOF_VOID_P == 8
@@ -22,20 +28,36 @@ typedef long long MPL_Int64;
2228#endif
2329#endif
2430
25- #if !defined(MPL_isnan64 )
31+ #if !defined(MPL_U64 )
2632#define MPL_U64 (u ) (* (MPL_Int64 *) &(u) )
33+ #endif /* MPL_U64 */
2734
35+ #if !defined(MPL_isnan64 )
2836#if !defined(_MSC_VER )
2937#define MPL_isnan64 (u ) \
30- ( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0
38+ ( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) != 0)) ? 1:0
3139#else
3240#define MPL_isnan64 (u ) \
3341 ( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((MPL_U64(u) & 0x000fffffffffffffi64) != 0)) ? 1:0
3442#endif
35-
3643#endif /* MPL_isnan64 */
3744
3845#if !defined(MPL_isinf64 )
39- // This beauty from translated from numpy.
40- #define MPL_isinf64 (x ) (!MPL_isnan64((x)) && MPL_isnan64((x)-(x)))
46+ #if !defined(_MSC_VER )
47+ #define MPL_isinf64 (u ) \
48+ ( (( MPL_U64(u) & 0x7ff0000000000000LL) == 0x7ff0000000000000LL) && ((MPL_U64(u) & 0x000fffffffffffffLL) == 0)) ? 1:0
49+ #else
50+ #define MPL_isinf64 (u ) \
51+ ( (( MPL_U64(u) & 0x7ff0000000000000i64) == 0x7ff0000000000000i64) && ((MPL_U64(u) & 0x000fffffffffffffi64) == 0)) ? 1:0
52+ #endif
53+ #endif /* MPL_isinf64 */
54+
55+ #if !defined(MPL_isfinite64 )
56+ #if !defined(_MSC_VER )
57+ #define MPL_isfinite64 (u ) \
58+ ( (( MPL_U64(u) & 0x7ff0000000000000LL) != 0x7ff0000000000000LL)) ? 1:0
59+ #else
60+ #define MPL_isfinite64 (u ) \
61+ ( (( MPL_U64(u) & 0x7ff0000000000000i64) != 0x7ff0000000000000i64)) ? 1:0
4162#endif
63+ #endif /* MPL_isfinite64 */
0 commit comments