diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-06-13 11:58:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-13 11:58:24 +0200 |
commit | 600b4c9c7b11622e4eb5ed1e5fd70b3d3f66170e (patch) | |
tree | 1b246c4e0efba31a91fbfafa15380f99c45708f0 /core/string | |
parent | f4ab76444fc166c592b9b11cb9bd51f3b51a2e77 (diff) | |
parent | 554c776e08c9ee35fa9e2677e02f4005c11ddbc0 (diff) |
Merge pull request #34668 from aaronfranke/to-string
[Core] Reformat structure string operators
Diffstat (limited to 'core/string')
-rw-r--r-- | core/string/ustring.cpp | 6 | ||||
-rw-r--r-- | core/string/ustring.h | 2 |
2 files changed, 5 insertions, 3 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index ec5ec3dd79..83ede0b11b 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1594,7 +1594,7 @@ String String::num_uint64(uint64_t p_num, int base, bool capitalize_hex) { return s; } -String String::num_real(double p_num) { +String String::num_real(double p_num, bool p_trailing) { if (Math::is_nan(p_num)) { return "nan"; } @@ -1669,8 +1669,10 @@ String String::num_real(double p_num) { dec_int /= 10; } sd = '.' + decimal; - } else { + } else if (p_trailing) { sd = ".0"; + } else { + sd = ""; } if (intn == 0) { diff --git a/core/string/ustring.h b/core/string/ustring.h index f05865165d..82cd3e1667 100644 --- a/core/string/ustring.h +++ b/core/string/ustring.h @@ -309,7 +309,7 @@ public: String unquote() const; static String num(double p_num, int p_decimals = -1); static String num_scientific(double p_num); - static String num_real(double p_num); + static String num_real(double p_num, bool p_trailing = true); static String num_int64(int64_t p_num, int base = 10, bool capitalize_hex = false); static String num_uint64(uint64_t p_num, int base = 10, bool capitalize_hex = false); static String chr(char32_t p_char); |