summaryrefslogtreecommitdiffstats
path: root/core/string/ustring.cpp
diff options
context:
space:
mode:
authorYuri Sizov <yuris@humnom.net>2023-09-05 15:14:36 +0200
committerYuri Sizov <yuris@humnom.net>2023-09-05 15:14:36 +0200
commit95b00b11b0c54ba6140aa3f794b717762882ba73 (patch)
treec05df4b22d328170f2666b2bd899a023fd19309a /core/string/ustring.cpp
parent59d3a36fbee958c9b049e58d242c75b052ddcbc4 (diff)
parent2b3bbde6dae2e251b1805b4dc731a18f5cb33629 (diff)
downloadredot-engine-95b00b11b0c54ba6140aa3f794b717762882ba73.tar.gz
Merge pull request #81328 from bruvzg/str_minus_zero
[String] Fix string conversion for -0.0 float values.
Diffstat (limited to 'core/string/ustring.cpp')
-rw-r--r--core/string/ustring.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp
index 3f11459a1e..f6a17cf1a7 100644
--- a/core/string/ustring.cpp
+++ b/core/string/ustring.cpp
@@ -1493,9 +1493,9 @@ String String::num(double p_num, int p_decimals) {
if (p_decimals < 0) {
p_decimals = 14;
- const double abs_num = ABS(p_num);
+ const double abs_num = Math::abs(p_num);
if (abs_num > 10) {
- // We want to align the digits to the above sane default, so we only
+ // We want to align the digits to the above reasonable default, so we only
// need to subtract log10 for numbers with a positive power of ten.
p_decimals -= (int)floor(log10(abs_num));
}
@@ -4890,8 +4890,8 @@ String String::sprintf(const Array &values, bool *error) const {
}
double value = values[value_index];
- bool is_negative = (value < 0);
- String str = String::num(ABS(value), min_decimals);
+ bool is_negative = signbit(value);
+ String str = String::num(Math::abs(value), min_decimals);
const bool is_finite = Math::is_finite(value);
// Pad decimals out.
@@ -4953,7 +4953,7 @@ String String::sprintf(const Array &values, bool *error) const {
String str = "(";
for (int i = 0; i < count; i++) {
double val = vec[i];
- String number_str = String::num(ABS(val), min_decimals);
+ String number_str = String::num(Math::abs(val), min_decimals);
const bool is_finite = Math::is_finite(val);
// Pad decimals out.