From 554c776e08c9ee35fa9e2677e02f4005c11ddbc0 Mon Sep 17 00:00:00 2001 From: Aaron Franke Date: Thu, 25 Feb 2021 09:54:50 -0500 Subject: Reformat structure string operators The order of numbers is not changed except for Transform2D. All logic is done inside of their structures (and not in Variant). For the number of decimals printed, they now use String::num_real which works best with real_t, except for Color which is fixed at 4 decimals (this is a reliable number of float digits when converting from 16-bpc so it seems like a good choice) --- core/string/ustring.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'core/string/ustring.cpp') 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) { -- cgit v1.2.3