1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

Calculator: Add a Rounding menu

This menu has three actions. Each one of them enable a different level
of rounding: to 0, 2 or 4 digits.
This commit is contained in:
Lucas CHOLLET 2022-09-22 16:54:46 +02:00 committed by Tim Flynn
parent 164094e161
commit de568f87fd
5 changed files with 35 additions and 5 deletions

View file

@ -113,10 +113,8 @@ void Keypad::set_to_0()
String Keypad::to_string() const
{
// TODO: Implement custom rounding length in the calculator.
constexpr auto maximum_precision = 6;
if (m_state == State::External)
return m_internal_value.to_string(maximum_precision);
return m_internal_value.to_string(m_displayed_fraction_length);
StringBuilder builder;
@ -136,3 +134,8 @@ String Keypad::to_string() const
return builder.to_string();
}
void Keypad::set_rounding_length(unsigned rounding_threshold)
{
m_displayed_fraction_length = rounding_threshold;
}