summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorAaron Franke <arnfranke@yahoo.com>2020-07-24 14:07:57 -0400
committerAaron Franke <arnfranke@yahoo.com>2020-07-27 18:38:53 -0400
commit56e2c6c7043ca14159284b7b1f07e95d6fcf9a9e (patch)
treea332137aefabdfc21f7f5f317096a1895e9f1dc9 /core
parent4e825539e590c6ce06e54fbb05571efce7fb181c (diff)
Make all String float conversion methods be 64-bit
Diffstat (limited to 'core')
-rw-r--r--core/io/json.cpp2
-rw-r--r--core/math/expression.cpp2
-rw-r--r--core/string_buffer.h2
-rw-r--r--core/ustring.cpp14
-rw-r--r--core/ustring.h7
-rw-r--r--core/variant.cpp4
-rw-r--r--core/variant_call.cpp2
7 files changed, 14 insertions, 19 deletions
diff --git a/core/io/json.cpp b/core/io/json.cpp
index b90841a5ef..8bdd6385cb 100644
--- a/core/io/json.cpp
+++ b/core/io/json.cpp
@@ -265,7 +265,7 @@ Error JSON::_get_token(const CharType *p_str, int &index, int p_len, Token &r_to
if (p_str[index] == '-' || (p_str[index] >= '0' && p_str[index] <= '9')) {
//a number
const CharType *rptr;
- double number = String::to_double(&p_str[index], &rptr);
+ double number = String::to_float(&p_str[index], &rptr);
index += (rptr - &p_str[index]);
r_token.type = TK_NUMBER;
r_token.value = number;
diff --git a/core/math/expression.cpp b/core/math/expression.cpp
index 13a49feb6b..735a30f6cc 100644
--- a/core/math/expression.cpp
+++ b/core/math/expression.cpp
@@ -1062,7 +1062,7 @@ Error Expression::_get_token(Token &r_token) {
r_token.type = TK_CONSTANT;
if (is_float) {
- r_token.value = num.to_double();
+ r_token.value = num.to_float();
} else {
r_token.value = num.to_int();
}
diff --git a/core/string_buffer.h b/core/string_buffer.h
index 956a6333d9..f9cf31075a 100644
--- a/core/string_buffer.h
+++ b/core/string_buffer.h
@@ -150,7 +150,7 @@ String StringBuffer<SHORT_BUFFER_SIZE>::as_string() {
template <int SHORT_BUFFER_SIZE>
double StringBuffer<SHORT_BUFFER_SIZE>::as_double() {
current_buffer_ptr()[string_length] = '\0';
- return String::to_double(current_buffer_ptr());
+ return String::to_float(current_buffer_ptr());
}
template <int SHORT_BUFFER_SIZE>
diff --git a/core/ustring.cpp b/core/ustring.cpp
index 572ad1af59..957caf1015 100644
--- a/core/ustring.cpp
+++ b/core/ustring.cpp
@@ -851,7 +851,7 @@ Vector<float> String::split_floats(const String &p_splitter, bool p_allow_empty)
end = len;
}
if (p_allow_empty || (end > from)) {
- ret.push_back(String::to_double(&c_str()[from]));
+ ret.push_back(String::to_float(&c_str()[from]));
}
if (end == len) {
@@ -880,7 +880,7 @@ Vector<float> String::split_floats_mk(const Vector<String> &p_splitters, bool p_
}
if (p_allow_empty || (end > from)) {
- ret.push_back(String::to_double(&c_str()[from]));
+ ret.push_back(String::to_float(&c_str()[from]));
}
if (end == len) {
@@ -2006,7 +2006,7 @@ done:
#define READING_EXP 3
#define READING_DONE 4
-double String::to_double(const char *p_str) {
+double String::to_float(const char *p_str) {
#ifndef NO_USE_STDLIB
return built_in_strtod<char>(p_str);
//return atof(p_str); DOES NOT WORK ON ANDROID(??)
@@ -2015,11 +2015,7 @@ double String::to_double(const char *p_str) {
#endif
}
-float String::to_float() const {
- return to_double();
-}
-
-double String::to_double(const CharType *p_str, const CharType **r_end) {
+double String::to_float(const CharType *p_str, const CharType **r_end) {
return built_in_strtod<CharType>(p_str, (CharType **)r_end);
}
@@ -2087,7 +2083,7 @@ int64_t String::to_int(const CharType *p_str, int p_len, bool p_clamp) {
return sign * integer;
}
-double String::to_double() const {
+double String::to_float() const {
if (empty()) {
return 0;
}
diff --git a/core/ustring.h b/core/ustring.h
index e745475f11..d37346fbd6 100644
--- a/core/ustring.h
+++ b/core/ustring.h
@@ -242,15 +242,14 @@ public:
static String md5(const uint8_t *p_md5);
static String hex_encode_buffer(const uint8_t *p_buffer, int p_len);
bool is_numeric() const;
- double to_double() const;
- float to_float() const;
+ double to_float() const;
int64_t hex_to_int(bool p_with_prefix = true) const;
int64_t bin_to_int(bool p_with_prefix = true) const;
int64_t to_int() const;
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 double to_float(const char *p_str);
+ static double to_float(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);
String capitalize() const;
String camelcase_to_underscore(bool lowercase = true) const;
diff --git a/core/variant.cpp b/core/variant.cpp
index afd01b3359..c19ce79e64 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -1573,7 +1573,7 @@ Variant::operator float() const {
case FLOAT:
return _data._float;
case STRING:
- return operator String().to_double();
+ return operator String().to_float();
default: {
return 0;
}
@@ -1591,7 +1591,7 @@ Variant::operator double() const {
case FLOAT:
return _data._float;
case STRING:
- return operator String().to_double();
+ return operator String().to_float();
default: {
return 0;
}
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 8afa24e63d..b96fd0c103 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -1405,7 +1405,7 @@ Variant Variant::construct(const Variant::Type p_type, const Variant **p_args, i
return (int64_t(*p_args[0]));
}
case FLOAT: {
- return real_t(*p_args[0]);
+ return double(*p_args[0]);
}
case STRING: {
return String(*p_args[0]);