Supports "%f" formatting value as inf float (#2324)

* Fixed when the float value of "%f" is inf, it should be formatted as "Inf" instead of "0.0"

* Replace std::isinf with ke::IsInfinite
This commit is contained in:
F1F88 2025-11-09 00:32:09 +08:00 committed by GitHub
parent 9952f62a33
commit 22cc68808c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -254,6 +254,12 @@ void AddFloat(char **buf_p, size_t &maxlen, double fval, int width, int prec, in
return; return;
} }
if (ke::IsInfinite(static_cast<float>(fval)))
{
AddString(buf_p, maxlen, "Inf", width, prec, flags | NOESCAPE);
return;
}
// default precision // default precision
if (prec < 0) if (prec < 0)
{ {