From bb18205d45d76541338136bf24741330c3c695a0 Mon Sep 17 00:00:00 2001 From: Chaitanya Mehta Date: Sat, 28 Nov 2020 22:50:04 -0500 Subject: [PATCH] Remove exponent value from operand length --- src/CalcViewModel/Common/CopyPasteManager.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/CalcViewModel/Common/CopyPasteManager.cpp b/src/CalcViewModel/Common/CopyPasteManager.cpp index ae24aad1..8f84eead 100644 --- a/src/CalcViewModel/Common/CopyPasteManager.cpp +++ b/src/CalcViewModel/Common/CopyPasteManager.cpp @@ -502,23 +502,32 @@ ULONG32 CopyPasteManager::StandardScientificOperandLength(Platform::String ^ ope { auto operandWstring = wstring(operand->Data()); const bool hasDecimal = operandWstring.find('.') != wstring::npos; + auto length = operandWstring.length(); if (hasDecimal) { - if (operandWstring.length() >= 2) + if (length >= 2) { if ((operandWstring[0] == L'0') && (operandWstring[1] == L'.')) { - return static_cast(operandWstring.length() - 2); + length -= 2; } else { - return static_cast(operandWstring.length() - 1); + length -= 1; } } } - return static_cast(operandWstring.length()); + auto exponentPos = operandWstring.find('e'); + const bool hasExponent = exponentPos != wstring::npos; + if (hasExponent) + { + auto expLength = operandWstring.substr(exponentPos).length(); + length -= expLength; + } + + return static_cast(length); } ULONG32 CopyPasteManager::ProgrammerOperandLength(Platform::String ^ operand, NumberBase numberBase)