mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-22 14:13:30 -07:00
Improved readablity of OperandLength and StandardScientificOperandLength
Moved to switch-case for OperandLength
This commit is contained in:
parent
a16fb9ff62
commit
5937345151
1 changed files with 15 additions and 22 deletions
|
@ -460,33 +460,26 @@ bool CopyPasteManager::TryOperandToULL(const wstring& operand, int numberBase, u
|
||||||
|
|
||||||
size_t CopyPasteManager::OperandLength(wstring operand, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase)
|
size_t CopyPasteManager::OperandLength(wstring operand, ViewMode mode, CategoryGroupType modeType, int programmerNumberBase)
|
||||||
{
|
{
|
||||||
if (mode == ViewMode::Standard || mode == ViewMode::Scientific)
|
if(modeType == CategoryGroupType::Converter) {
|
||||||
{
|
|
||||||
return StandardScientificOperandLength(operand);
|
|
||||||
}
|
|
||||||
else if (mode == ViewMode::Programmer)
|
|
||||||
{
|
|
||||||
return ProgrammerOperandLength(operand, programmerNumberBase);
|
|
||||||
}
|
|
||||||
else if (modeType == CategoryGroupType::Converter)
|
|
||||||
{
|
|
||||||
return operand.length();
|
return operand.length();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
switch(mode) {
|
||||||
|
case ViewMode::Standard:
|
||||||
|
case ViewMode::Scientific:
|
||||||
|
return StandardScientificOperandLength(operand);
|
||||||
|
|
||||||
|
case ViewMode::Programmer:
|
||||||
|
return ProgrammerOperandLength(operand, programmerNumberBase);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t CopyPasteManager::StandardScientificOperandLength(wstring operand)
|
size_t CopyPasteManager::StandardScientificOperandLength(wstring operand)
|
||||||
{
|
{
|
||||||
// Loop until a decimal is found or if the end is reached
|
const bool hasDecimal = operand.find('.') != std::wstring::npos;
|
||||||
bool hasDecimal = false;
|
|
||||||
for (size_t i = 0; i < operand.length() && !hasDecimal; i++)
|
|
||||||
{
|
|
||||||
if (operand[i] == L'.')
|
|
||||||
{
|
|
||||||
hasDecimal = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hasDecimal)
|
if (hasDecimal)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue