diff --git a/src/compile.cpp b/src/compile.cpp index 6837e9e7b1..50e2bfb9e2 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -2590,7 +2590,7 @@ doubleToInt(int64_t a) double f = bitsToDouble(a); switch (fpclassify(f)) { case FP_NAN: return 0; - case FP_INFINITE: return isinf(f) == 1 ? INT32_MAX : INT32_MIN; + case FP_INFINITE: return signbit(f) ? INT32_MIN : INT32_MAX; default: return f >= INT32_MAX ? INT32_MAX : (f <= INT32_MIN ? INT32_MIN : static_cast(f)); } @@ -2602,7 +2602,7 @@ doubleToLong(int64_t a) double f = bitsToDouble(a); switch (fpclassify(f)) { case FP_NAN: return 0; - case FP_INFINITE: return isinf(f) == 1 ? INT64_MAX : INT64_MIN; + case FP_INFINITE: return signbit(f) ? INT64_MIN : INT64_MAX; default: return f >= INT64_MAX ? INT64_MAX : (f <= INT64_MIN ? INT64_MIN : static_cast(f)); } @@ -2750,7 +2750,7 @@ floatToInt(int32_t a) float f = bitsToFloat(a); switch (fpclassify(f)) { case FP_NAN: return 0; - case FP_INFINITE: return isinf(f) == 1 ? INT32_MAX : INT32_MIN; + case FP_INFINITE: return signbit(f) ? INT32_MIN : INT32_MAX; default: return f >= INT32_MAX ? INT32_MAX : (f <= INT32_MIN ? INT32_MIN : static_cast(f)); } @@ -2762,7 +2762,7 @@ floatToLong(int32_t a) float f = bitsToFloat(a); switch (fpclassify(f)) { case FP_NAN: return 0; - case FP_INFINITE: return isinf(f) == 1 ? INT64_MAX : INT64_MIN; + case FP_INFINITE: return signbit(f) ? INT64_MIN : INT64_MAX; default: return static_cast(f); } } diff --git a/src/interpret.cpp b/src/interpret.cpp index e9f715d1de..6e18a3d3e7 100644 --- a/src/interpret.cpp +++ b/src/interpret.cpp @@ -1081,7 +1081,7 @@ interpret3(Thread* t, const int base) double f = popDouble(t); switch (fpclassify(f)) { case FP_NAN: pushInt(t, 0); break; - case FP_INFINITE: pushInt(t, isinf(f) == 1 ? INT32_MAX : INT32_MIN); break; + case FP_INFINITE: pushInt(t, signbit(f) ? INT32_MIN : INT32_MAX); break; default: pushInt (t, f >= INT32_MAX ? INT32_MAX : (f <= INT32_MIN ? INT32_MIN : static_cast(f))); @@ -1093,8 +1093,7 @@ interpret3(Thread* t, const int base) double f = popDouble(t); switch (fpclassify(f)) { case FP_NAN: pushLong(t, 0); break; - case FP_INFINITE: pushLong(t, isinf(f) == 1 ? INT64_MAX : INT64_MIN); - break; + case FP_INFINITE: pushLong(t, signbit(f) ? INT64_MIN : INT64_MAX); break; default: pushLong (t, f >= INT64_MAX ? INT64_MAX : (f <= INT64_MIN ? INT64_MIN : static_cast(f))); @@ -1298,7 +1297,7 @@ interpret3(Thread* t, const int base) float f = popFloat(t); switch (fpclassify(f)) { case FP_NAN: pushInt(t, 0); break; - case FP_INFINITE: pushInt(t, isinf(f) == 1 ? INT32_MAX : INT32_MIN); break; + case FP_INFINITE: pushInt(t, signbit(f) ? INT32_MIN : INT32_MAX); break; default: pushInt(t, f >= INT32_MAX ? INT32_MAX : (f <= INT32_MIN ? INT32_MIN : static_cast(f))); break; @@ -1309,7 +1308,7 @@ interpret3(Thread* t, const int base) float f = popFloat(t); switch (fpclassify(f)) { case FP_NAN: pushLong(t, 0); break; - case FP_INFINITE: pushLong(t, isinf(f) == 1 ? INT64_MAX : INT64_MIN); + case FP_INFINITE: pushLong(t, signbit(f) ? INT64_MIN : INT64_MAX); break; default: pushLong(t, static_cast(f)); break; }