diff --git a/core/math/plane.cpp b/core/math/plane.cpp index 6881ad40148..926634f1c4e 100644 --- a/core/math/plane.cpp +++ b/core/math/plane.cpp @@ -175,5 +175,5 @@ bool Plane::is_equal_approx(const Plane &p_plane) const { } Plane::operator String() const { - return "[N: " + normal.operator String() + ", D: " + String::num_real(d, false) + "]"; + return "[N: " + normal.operator String() + ", D: " + String::num_real(d, true) + "]"; } diff --git a/core/math/quaternion.cpp b/core/math/quaternion.cpp index 11bfcc1a6f5..a6eb98780c9 100644 --- a/core/math/quaternion.cpp +++ b/core/math/quaternion.cpp @@ -202,7 +202,7 @@ Quaternion Quaternion::cubic_slerp(const Quaternion &p_b, const Quaternion &p_pr } Quaternion::operator String() const { - return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ", " + String::num_real(z, false) + ", " + String::num_real(w, false) + ")"; + return "(" + String::num_real(x, true) + ", " + String::num_real(y, true) + ", " + String::num_real(z, true) + ", " + String::num_real(w, true) + ")"; } Vector3 Quaternion::get_axis() const { diff --git a/core/math/vector2.cpp b/core/math/vector2.cpp index a27227905ca..a015b713875 100644 --- a/core/math/vector2.cpp +++ b/core/math/vector2.cpp @@ -190,7 +190,7 @@ bool Vector2::is_equal_approx(const Vector2 &p_v) const { } Vector2::operator String() const { - return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ")"; + return "(" + String::num_real(x, true) + ", " + String::num_real(y, true) + ")"; } Vector2::operator Vector2i() const { diff --git a/core/math/vector3.cpp b/core/math/vector3.cpp index f94f39b7f2b..dcb2ce8ef8a 100644 --- a/core/math/vector3.cpp +++ b/core/math/vector3.cpp @@ -138,7 +138,7 @@ bool Vector3::is_equal_approx(const Vector3 &p_v) const { } Vector3::operator String() const { - return "(" + String::num_real(x, false) + ", " + String::num_real(y, false) + ", " + String::num_real(z, false) + ")"; + return "(" + String::num_real(x, true) + ", " + String::num_real(y, true) + ", " + String::num_real(z, true) + ")"; } Vector3::operator Vector3i() const { diff --git a/core/string/ustring.cpp b/core/string/ustring.cpp index 5d998d22d41..f7f9e13f618 100644 --- a/core/string/ustring.cpp +++ b/core/string/ustring.cpp @@ -1425,7 +1425,11 @@ String String::num(double p_num, int p_decimals) { if (buf[z] == '0') { buf[z] = 0; } else if (buf[z] == '.') { - buf[z] = 0; + if (z == 254) { + buf[z] = 0; + } else { + buf[z + 1] = '0'; + } break; } else { break; diff --git a/tests/core/math/test_aabb.h b/tests/core/math/test_aabb.h index 526972a82f1..6b9dd17dc8c 100644 --- a/tests/core/math/test_aabb.h +++ b/tests/core/math/test_aabb.h @@ -48,7 +48,7 @@ TEST_CASE("[AABB] Constructor methods") { TEST_CASE("[AABB] String conversion") { CHECK_MESSAGE( - String(AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6))) == "[P: (-1.5, 2, -2.5), S: (4, 5, 6)]", + String(AABB(Vector3(-1.5, 2, -2.5), Vector3(4, 5, 6))) == "[P: (-1.5, 2, -2.5), S: (4.0, 5.0, 6.0)]", "The string representation should match the expected value."); } diff --git a/tests/core/math/test_color.h b/tests/core/math/test_color.h index 51c3bc8bdc8..42e1975bad8 100644 --- a/tests/core/math/test_color.h +++ b/tests/core/math/test_color.h @@ -140,7 +140,7 @@ TEST_CASE("[Color] Conversion methods") { cyan.to_rgba64() == 0x0000'ffff'ffff'ffff, "The returned 64-bit BGR number should match the expected value."); CHECK_MESSAGE( - String(cyan) == "(0, 1, 1, 1)", + String(cyan) == "(0.0, 1.0, 1.0, 1.0)", "The string representation should match the expected value."); } diff --git a/tests/core/math/test_rect2.h b/tests/core/math/test_rect2.h index 0b1106ac3cf..f306d0a9fdc 100644 --- a/tests/core/math/test_rect2.h +++ b/tests/core/math/test_rect2.h @@ -57,7 +57,7 @@ TEST_CASE("[Rect2] Constructor methods") { TEST_CASE("[Rect2] String conversion") { // Note: This also depends on the Vector2 string representation. CHECK_MESSAGE( - String(Rect2(0, 100, 1280, 720)) == "[P: (0, 100), S: (1280, 720)]", + String(Rect2(0, 100, 1280, 720)) == "[P: (0.0, 100.0), S: (1280.0, 720.0)]", "The string representation should match the expected value."); }