mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Fixed the decimal number with point in programmer memory
This commit is contained in:
parent
fd22f75190
commit
62d0c42f75
3 changed files with 18 additions and 17 deletions
|
@ -1188,19 +1188,20 @@ void StandardCalculatorViewModel::SetCalculatorType(ViewMode targetState)
|
|||
{
|
||||
case ViewMode::Standard:
|
||||
IsStandard = true;
|
||||
ResetRadix();
|
||||
ResetRadixAndUpdateMemory(true);
|
||||
SetPrecision(StandardModePrecision);
|
||||
UpdateMaxIntDigits();
|
||||
break;
|
||||
|
||||
case ViewMode::Scientific:
|
||||
IsScientific = true;
|
||||
ResetRadix();
|
||||
ResetRadixAndUpdateMemory(true);
|
||||
SetPrecision(ScientificModePrecision);
|
||||
break;
|
||||
|
||||
case ViewMode::Programmer:
|
||||
IsProgrammer = true;
|
||||
ResetRadixAndUpdateMemory(false);
|
||||
SetPrecision(ProgrammerModePrecision);
|
||||
break;
|
||||
}
|
||||
|
@ -1226,11 +1227,18 @@ String ^ StandardCalculatorViewModel::GetLocalizedStringFormat(String ^ format,
|
|||
return LocalizationStringUtil::GetLocalizedString(format, displayValue);
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::ResetRadix()
|
||||
void StandardCalculatorViewModel::ResetRadixAndUpdateMemory(bool resetRadix)
|
||||
{
|
||||
if (resetRadix)
|
||||
{
|
||||
AreHEXButtonsEnabled = false;
|
||||
CurrentRadixType = NumberBase::DecBase;
|
||||
m_standardCalculatorManager.SetRadix(RadixType::Decimal);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_standardCalculatorManager.SetMemorizedNumbersString();
|
||||
}
|
||||
}
|
||||
|
||||
void StandardCalculatorViewModel::SetPrecision(int32_t precision)
|
||||
|
|
|
@ -283,7 +283,7 @@ namespace CalculatorApp
|
|||
void Recalculate(bool fromHistory = false);
|
||||
bool IsOperator(CalculationManager::Command cmdenum);
|
||||
void SetMemorizedNumbersString();
|
||||
void ResetRadix();
|
||||
void ResetRadixAndUpdateMemory(bool resetRadix);
|
||||
|
||||
void SetPrecision(int32_t precision);
|
||||
void UpdateMaxIntDigits()
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace CalculatorUnitTests
|
|||
viewModel->IsStandard = true;
|
||||
viewModel->IsScientific = false;
|
||||
viewModel->IsProgrammer = false;
|
||||
viewModel->ResetRadix();
|
||||
viewModel->ResetRadixAndUpdateMemory(true);
|
||||
viewModel->SetPrecision(StandardModePrecision);
|
||||
}
|
||||
else if (mode == 1)
|
||||
|
@ -50,7 +50,7 @@ namespace CalculatorUnitTests
|
|||
viewModel->IsScientific = true;
|
||||
viewModel->IsProgrammer = false;
|
||||
viewModel->IsStandard = false;
|
||||
viewModel->ResetRadix();
|
||||
viewModel->ResetRadixAndUpdateMemory(true);
|
||||
viewModel->SetPrecision(ScientificModePrecision);
|
||||
}
|
||||
else if (mode == 2)
|
||||
|
@ -58,6 +58,7 @@ namespace CalculatorUnitTests
|
|||
viewModel->IsProgrammer = true;
|
||||
viewModel->IsScientific = false;
|
||||
viewModel->IsStandard = false;
|
||||
viewModel->ResetRadixAndUpdateMemory(false);
|
||||
viewModel->SetPrecision(ProgrammerModePrecision);
|
||||
}
|
||||
}
|
||||
|
@ -803,14 +804,6 @@ namespace CalculatorUnitTests
|
|||
MemoryItemViewModel ^ memorySlotScientific = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001.1"), memorySlotScientific->Value);
|
||||
ChangeMode(m_viewModel, 2 /*Programmer*/);
|
||||
TESTITEM items2[] = {
|
||||
{ NumbersAndOperatorsEnum::One, L"1", L"" }, { NumbersAndOperatorsEnum::Zero, L"10", L"" },
|
||||
{ NumbersAndOperatorsEnum::Zero, L"100", L"" }, { NumbersAndOperatorsEnum::One, L"1,001", L"" },
|
||||
{ NumbersAndOperatorsEnum::None, L"", L"" },
|
||||
};
|
||||
ValidateViewModelByCommands(m_viewModel, items2, true);
|
||||
m_viewModel->OnMemoryButtonPressed();
|
||||
m_viewModel->OnMemoryItemPressed(ref new Platform::Box<int>(0));
|
||||
MemoryItemViewModel ^ memorySlotProgrammer = (MemoryItemViewModel ^) m_viewModel->MemorizedNumbers->GetAt(0);
|
||||
VERIFY_ARE_EQUAL(Platform::StringReference(L"1,001"), memorySlotProgrammer->Value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue