diff options
-rw-r--r-- | core/ustring.cpp | 10 | ||||
-rw-r--r-- | core/ustring.h | 4 | ||||
-rw-r--r-- | modules/gdscript/gdscript_tokenizer.cpp | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/core/ustring.cpp b/core/ustring.cpp index 698187cc29..884e7f25eb 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -1660,7 +1660,7 @@ int64_t String::hex_to_int(bool p_with_prefix) const { return hex * sign; } -int64_t String::bin_to_int64(bool p_with_prefix) const { +int64_t String::bin_to_int(bool p_with_prefix) const { if (p_with_prefix && length() < 3) { return 0; } @@ -1725,7 +1725,7 @@ int64_t String::to_int() const { return integer * sign; } -int String::to_int(const char *p_str, int p_len) { +int64_t String::to_int(const char *p_str, int p_len) { int to = 0; if (p_len >= 0) { to = p_len; @@ -1735,13 +1735,13 @@ int String::to_int(const char *p_str, int p_len) { } } - int integer = 0; - int sign = 1; + int64_t integer = 0; + int64_t sign = 1; for (int i = 0; i < to; i++) { char c = p_str[i]; if (c >= '0' && c <= '9') { - ERR_FAIL_COND_V_MSG(integer > INT32_MAX / 10, 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(integer > INT64_MAX / 10, sign == 1 ? INT64_MAX : INT64_MIN, "Cannot represent " + String(p_str).substr(0, to) + " as an integer, provided value is " + (sign == 1 ? "too big." : "too small.")); integer *= 10; integer += c - '0'; diff --git a/core/ustring.h b/core/ustring.h index c48bca5552..a86849b932 100644 --- a/core/ustring.h +++ b/core/ustring.h @@ -247,9 +247,9 @@ public: float to_float() const; int64_t hex_to_int(bool p_with_prefix = true) const; - int64_t bin_to_int64(bool p_with_prefix = true) const; + int64_t bin_to_int(bool p_with_prefix = true) const; int64_t to_int() const; - static int to_int(const char *p_str, int p_len = -1); + static int64_t to_int(const char *p_str, int p_len = -1); static double to_double(const char *p_str); static double to_double(const CharType *p_str, const CharType **r_end = nullptr); static int64_t to_int(const CharType *p_str, int p_len = -1, bool p_clamp = false); diff --git a/modules/gdscript/gdscript_tokenizer.cpp b/modules/gdscript/gdscript_tokenizer.cpp index f87b6367a4..82def3f877 100644 --- a/modules/gdscript/gdscript_tokenizer.cpp +++ b/modules/gdscript/gdscript_tokenizer.cpp @@ -955,7 +955,7 @@ void GDScriptTokenizerText::_advance() { int64_t val = str.hex_to_int(); _make_constant(val); } else if (bin_found) { - int64_t val = str.bin_to_int64(); + int64_t val = str.bin_to_int(); _make_constant(val); } else if (period_found || exponent_found) { double val = str.to_double(); |