AK: Allow %m.nf specifier for double/float in printf to set fraction with

This patch adds the missing part for the printf of double values to specify
the length of the fraction part. For GVariant, a default of %.2 is used.
This commit is contained in:
Emanuel Sprung 2020-04-06 23:27:15 +02:00 committed by Andreas Kling
commit 154dcd1ed6
Notes: sideshowbarker 2024-07-19 07:50:18 +09:00
2 changed files with 20 additions and 10 deletions

View file

@ -398,7 +398,7 @@ String Variant::to_string() const
case Type::UnsignedInt:
return String::number(as_uint());
case Type::Float:
return String::format("%f", (double)as_float());
return String::format("%.2f", (double)as_float());
case Type::String:
return as_string();
case Type::Bitmap: