Accept exponential numbers without -/+ sign. (#270)
* add exponential without sign support * Add unit tests * fix formatting * remove extra spaces * modify unit tests
This commit is contained in:
@@ -40,7 +40,7 @@ static const wstring c_uIntSuffixes = L"[uU]?[lL]{0,2}";
|
||||
static const array<wregex, 1> standardModePatterns = { wregex(c_wspc + c_signedDecFloat + c_wspc) };
|
||||
static const array<wregex, 2> scientificModePatterns = {
|
||||
wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + c_wspcRParens),
|
||||
wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + L"[e]([+]|[-])+\\d+" + c_wspcRParens)
|
||||
wregex(L"(" + c_wspc + L"[-+]?)|(" + c_wspcLParenSigned + L")" + c_signedDecFloat + L"e[+-]?\\d+" + c_wspcRParens)
|
||||
};
|
||||
static const array<array<wregex, 5>, 4> programmerModePatterns = {
|
||||
{ // Hex numbers like 5F, 4A0C, 0xa9, 0xFFull, 47CDh
|
||||
|
@@ -881,14 +881,25 @@ void StandardCalculatorViewModel::OnPaste(String ^ pastedString, ViewMode mode)
|
||||
}
|
||||
}
|
||||
|
||||
// Handle exponent and exponent sign (...e+... or ...e-...)
|
||||
// Handle exponent and exponent sign (...e+... or ...e-... or ...e...)
|
||||
if (mappedNumOp == NumbersAndOperatorsEnum::Exp)
|
||||
{
|
||||
++it;
|
||||
if (!(MapCharacterToButtonId(*it, canSendNegate) == NumbersAndOperatorsEnum::Add))
|
||||
//Check the following item
|
||||
switch (MapCharacterToButtonId(*(it + 1), canSendNegate))
|
||||
{
|
||||
case NumbersAndOperatorsEnum::Subtract:
|
||||
{
|
||||
Command cmdNegate = ConvertToOperatorsEnum(NumbersAndOperatorsEnum::Negate);
|
||||
m_standardCalculatorManager.SendCommand(cmdNegate);
|
||||
++it;
|
||||
}
|
||||
break;
|
||||
case NumbersAndOperatorsEnum::Add:
|
||||
{
|
||||
//Nothing to do, skip to the next item
|
||||
++it;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user