Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle "Subtract" ( "-" ) Operation as "Toggle Sign" ( "+/-" ) in Special Cases to fix #1541 and #1311 #2035

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

dhikshithrm
Copy link

@dhikshithrm dhikshithrm commented Aug 6, 2023

Fixes #1541

Fixes #1311

This Pull request addresses these following issues:

  1. Typing the most negative number by numpad not possible #1541

  2. Entering negative exponents in Scientific mode is not supported #1311

by Handling "Subtract" ("-") Binary operator as "Toggle Sign" ("+/-") in Special cases.

Description of the changes:

  • To solve Entering negative exponents in Scientific mode is not supported #1311, I modified IsGuiSettingOpCode method inside src/CalcManager/CEngine/CalcUtils.cpp to save IDC_EXP in CCalcEngine::m_nLastCom to check if next input is IDC_SUB (Subtract Operation) and also m_nLastCom is IDC_EXP so we can redirect this operation into IDC_SIGN (+/-) operation.
  • To Solve Typing the most negative number by numpad not possible #1541, I created a boolean flag CCalcEngine:m_bFlagSign to store, subtracting with zero as a "Toggle Sign" Operation (IDC_SIGN), so that the following digit inputs (the second operand) will be of negative sign, following is the piece of code from the pull request where the same is done.
        /*
            Addressing issues:
                #1541 https://github.com/microsoft/calculator/issues/1541
                #1311 https://github.com/microsoft/calculator/issues/1311
            Solution:
                Consider the previous '-' Binary Op as a '+/-' sign value if
                the first opnd is 0.
        */
        if (m_bFlagSign)
        {
            wParam = IDC_SIGN;
            m_bFlagSign = false;
        }

How changes were validated:

Output for #1541

Recording.2023-08-06.203946.mp4

Output for #1311

Recording.2023-08-06.203512.mp4

@dhikshithrm dhikshithrm changed the title Handle - Handle "Subtract" ( "-" ) Operation as "Toggle Sign" ( "+/-" ) in Special Cases to fix #1541 and #1311 Aug 6, 2023
@dhikshithrm
Copy link
Author

@microsoft-github-policy-service agree

@dhikshithrm
Copy link
Author

Hi @grochocki, @hanzhang54

can you please review these changes.

@tian-lt
Copy link
Contributor

tian-lt commented Aug 21, 2023

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@dhikshithrm
Copy link
Author

dhikshithrm commented Aug 21, 2023

I have not changed the UnitTests module to expect the new changes, because the Unit Test module was taking long to run on my PC, wasn't clear if they passed or failed, getting a black screen with two numbers, and I could not find a relevant test function that's testing these cases:

  1. 2.6e-2 = 0.026
  2. -128 input

I think that's why UnitTests x64 has failed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants