mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-12-23 20:36:53 +01:00
Tweak 64-bit integer overflow message to mention that it's a signed type
(cherry picked from commit 7b5bf3af192be83afab19bbfcd029d97af0da8cd)
This commit is contained in:
parent
c3bb14f49e
commit
0b8e21cf74
@ -1754,7 +1754,7 @@ int String::hex_to_int(bool p_with_prefix) const {
|
||||
}
|
||||
// Check for overflow/underflow, with special case to ensure INT32_MIN does not result in error
|
||||
bool overflow = ((hex > INT32_MAX / 16) && (sign == 1 || (sign == -1 && hex != (INT32_MAX >> 4) + 1))) || (sign == -1 && hex == (INT32_MAX >> 4) + 1 && c > '0');
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as a 32-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
hex *= 16;
|
||||
hex += n;
|
||||
s++;
|
||||
@ -1796,7 +1796,7 @@ int64_t String::hex_to_int64(bool p_with_prefix) const {
|
||||
return 0;
|
||||
}
|
||||
bool overflow = ((hex > INT64_MAX / 16) && (sign == 1 || (sign == -1 && hex != (INT64_MAX >> 4) + 1))) || (sign == -1 && hex == (INT64_MAX >> 4) + 1 && c > '0');
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as a 64-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
hex *= 16;
|
||||
hex += n;
|
||||
s++;
|
||||
@ -1838,7 +1838,7 @@ int64_t String::bin_to_int64(bool p_with_prefix) const {
|
||||
}
|
||||
// Check for overflow/underflow, with special case to ensure INT64_MIN does not result in error
|
||||
bool overflow = ((binary > INT64_MAX / 2) && (sign == 1 || (sign == -1 && binary != (INT64_MAX >> 1) + 1))) || (sign == -1 && binary == (INT64_MAX >> 1) + 1 && c > '0');
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as a 64-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
binary *= 2;
|
||||
binary += n;
|
||||
s++;
|
||||
@ -1861,7 +1861,7 @@ int String::to_int() const {
|
||||
CharType c = operator[](i);
|
||||
if (c >= '0' && c <= '9') {
|
||||
bool overflow = (integer > INT32_MAX / 10) || (integer == INT32_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + *this + " as a 32-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
integer *= 10;
|
||||
integer += c - '0';
|
||||
|
||||
@ -1907,7 +1907,7 @@ int64_t String::to_int64() const {
|
||||
CharType c = operator[](i);
|
||||
if (c >= '0' && c <= '9') {
|
||||
bool overflow = (integer > INT64_MAX / 10) || (integer == INT64_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as 64-bit integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + *this + " as a 64-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
integer *= 10;
|
||||
integer += c - '0';
|
||||
|
||||
@ -1936,7 +1936,7 @@ int String::to_int(const char *p_str, int p_len) {
|
||||
char c = p_str[i];
|
||||
if (c >= '0' && c <= '9') {
|
||||
bool overflow = (integer > INT32_MAX / 10) || (integer == INT32_MAX / 10 && ((sign == 1 && c > '7') || (sign == -1 && c > '8')));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_COND_V_MSG(overflow, sign == 1 ? INT32_MAX : INT32_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as a 32-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
integer *= 10;
|
||||
integer += c - '0';
|
||||
|
||||
@ -2289,7 +2289,7 @@ int64_t String::to_int(const CharType *p_str, int p_len) {
|
||||
while (*str && str != limit) {
|
||||
number += *(str++);
|
||||
}
|
||||
ERR_FAIL_V_MSG(sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + number + " as integer, provided value is " + (sign == 1 ? "too big." : "too small."));
|
||||
ERR_FAIL_V_MSG(sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + number + " as a 64-bit signed integer, since the value is " + (sign == 1 ? "too large." : "too small."));
|
||||
}
|
||||
integer *= 10;
|
||||
integer += c - '0';
|
||||
|
Loading…
Reference in New Issue
Block a user