mirror of
https://github.com/corda/corda.git
synced 2025-01-05 20:54:13 +00:00
use signbit instead of isinf to determine floating point sign
glibc's use of isinf's return value to indicate sign is a non-standard extension which can't be relied upon on other platforms.
This commit is contained in:
parent
b98abe3f94
commit
20a290b992
@ -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<int32_t>(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<int64_t>(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<int32_t>(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<int64_t>(f);
|
||||
}
|
||||
}
|
||||
|
@ -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<int32_t>(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<int64_t>(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<int32_t>(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<int64_t>(f)); break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user