Calculator: Use format instead of printf.

This also fixes a graphical bug where the decimal point was always
rendered. The number four was represented as '4.' instead of '4'. Now
the decimal point is only shown when there are decimal places.
This commit is contained in:
asynts 2020-10-04 20:32:06 +02:00 committed by Andreas Kling
parent 31feefff5e
commit 206e48abb5
Notes: sideshowbarker 2024-07-19 02:02:36 +09:00

View file

@ -162,10 +162,10 @@ String Keypad::to_string() const
StringBuilder builder;
if (m_negative)
builder.append("-");
builder.appendf("%ld.", m_int_value);
builder.appendff("{}", m_int_value);
if (m_frac_length > 0)
builder.appendf("%0*ld", m_frac_length, m_frac_value);
builder.appendff(".{:0{}}", m_frac_value, m_frac_length);
return builder.to_string();
}