diff options
author | Aaron Franke <arnfranke@yahoo.com> | 2020-06-03 00:04:04 -0400 |
---|---|---|
committer | Aaron Franke <arnfranke@yahoo.com> | 2020-06-03 00:04:15 -0400 |
commit | 25c978730bd6d09091ae0f148766f6833e6e1400 (patch) | |
tree | b44575ee478ca7b3d103ac5bd804c852c62f03be /core | |
parent | e5ae89775a375106eaad93e2fd1607748c0fa005 (diff) |
Rename String bin_to_int64 to bin_to_int
And also change String static to_int(const char *) to return int64_t
Diffstat (limited to 'core')
-rw-r--r-- | core/ustring.cpp | 10 | ||||
-rw-r--r-- | core/ustring.h | 4 |
2 files changed, 7 insertions, 7 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); |