mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
4 for bin 3 for oct
This commit is contained in:
parent
5a123eb840
commit
f25b6217a6
1 changed files with 22 additions and 0 deletions
|
@ -137,6 +137,10 @@ StandardCalculatorViewModel::StandardCalculatorViewModel()
|
|||
String ^ StandardCalculatorViewModel::LocalizeDisplayValue(_In_ wstring const& displayValue)
|
||||
{
|
||||
wstring result(displayValue);
|
||||
if (CurrentRadixType == NumberBase::BinBase || CurrentRadixType == NumberBase::OctBase)
|
||||
{
|
||||
result = AddPadding(result);
|
||||
}
|
||||
LocalizationSettings::GetInstance()->LocalizeDisplayValue(&result);
|
||||
return ref new Platform::String(result.c_str());
|
||||
}
|
||||
|
@ -1545,6 +1549,24 @@ wstring StandardCalculatorViewModel::AddPadding(wstring binaryString)
|
|||
{
|
||||
return binaryString;
|
||||
}
|
||||
if (CurrentRadixType == NumberBase::BinBase)
|
||||
{
|
||||
size_t pad = 4 - LengthWithoutPadding(binaryString) % 4;
|
||||
if (pad == 4)
|
||||
{
|
||||
pad = 0;
|
||||
}
|
||||
return wstring(pad, L'0') + binaryString;
|
||||
}
|
||||
else if (CurrentRadixType == NumberBase::OctBase)
|
||||
{
|
||||
size_t pad = 3 - LengthWithoutPadding(binaryString) % 3;
|
||||
if (pad == 3)
|
||||
{
|
||||
pad = 0;
|
||||
}
|
||||
return wstring(pad, L'0') + binaryString;
|
||||
}
|
||||
size_t pad = 4 - LengthWithoutPadding(binaryString) % 4;
|
||||
if (pad == 4)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue