From 9789c6e911901a439cddf998a34c4ea88843431b Mon Sep 17 00:00:00 2001 From: F1F88 <0xF1F88@gmail.com> Date: Fri, 30 May 2025 14:22:35 +0800 Subject: [PATCH 1/2] Fixed when the float value of "%f" is inf, it should be formatted as "Inf" instead of "0.0" --- core/logic/sprintf.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index 6263ddfb70..c8f69f8b32 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -254,6 +254,12 @@ void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, in return; } + if (std::isinf(fval)) + { + AddString(buf_p, maxlen, "Inf", width, prec, flags | NOESCAPE); + return; + } + // default precision if (prec < 0) { From ee9e9ac1402e990f63f50749a26888085f9de24b Mon Sep 17 00:00:00 2001 From: F1F88 <0xF1F88@gmail.com> Date: Fri, 30 May 2025 15:46:21 +0800 Subject: [PATCH 2/2] Replace std::isinf with ke::IsInfinite --- core/logic/sprintf.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/logic/sprintf.cpp b/core/logic/sprintf.cpp index c8f69f8b32..b872194f70 100644 --- a/core/logic/sprintf.cpp +++ b/core/logic/sprintf.cpp @@ -254,7 +254,7 @@ void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, in return; } - if (std::isinf(fval)) + if (ke::IsInfinite(static_cast(fval))) { AddString(buf_p, maxlen, "Inf", width, prec, flags | NOESCAPE); return;