Fix the operand order of logbasex for consistency (#1115)

* Fix #851: inconsistent operand order for log_y(x)

 - fixed the bug in scioper.cpp
 - changed the related test in CalculatorUnitTests
 - also changed the text in GraphingNumpad

* Change the name of LogBaseX for consistency

basically every occurence is repalced by logbasey, except
for the localized string for narrator, which I left for
the localization team to fix.

* Fix the test

* Revert GraphingNumPad.cpp

* Fixup according to review
This commit is contained in:
dovisutu 2020-04-04 01:34:59 +08:00 committed by GitHub
parent 2705bef6e9
commit 5403adc914
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 37 additions and 37 deletions

View file

@ -35,7 +35,7 @@ namespace
IDC_ADD,2, IDC_SUB,2, IDC_ADD,2, IDC_SUB,2,
IDC_RSHF,3, IDC_LSHF,3, IDC_RSHFL,3, IDC_RSHF,3, IDC_LSHF,3, IDC_RSHFL,3,
IDC_MOD,3, IDC_DIV,3, IDC_MUL,3, IDC_MOD,3, IDC_DIV,3, IDC_MUL,3,
IDC_PWR,4, IDC_ROOT,4, IDC_LOGBASEX,4 }; IDC_PWR,4, IDC_ROOT,4, IDC_LOGBASEY,4 };
for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2) for (unsigned int iPrec = 0; iPrec < size(rgbPrec); iPrec += 2)
{ {
@ -948,7 +948,7 @@ static const std::unordered_map<int, FunctionNameElement> operatorStringTable =
{ IDC_SIGN, { SIDS_NEGATE } }, { IDC_SIGN, { SIDS_NEGATE } },
{ IDC_DEGREES, { SIDS_DEGREES } }, { IDC_DEGREES, { SIDS_DEGREES } },
{ IDC_POW2, { SIDS_TWOPOWX } }, { IDC_POW2, { SIDS_TWOPOWX } },
{ IDC_LOGBASEX, { SIDS_LOGBASEX } }, { IDC_LOGBASEY, { SIDS_LOGBASEY } },
{ IDC_ABS, { SIDS_ABS } }, { IDC_ABS, { SIDS_ABS } },
{ IDC_CEIL, { SIDS_CEIL } }, { IDC_CEIL, { SIDS_CEIL } },
{ IDC_FLOOR, { SIDS_FLOOR } }, { IDC_FLOOR, { SIDS_FLOOR } },

View file

@ -158,8 +158,8 @@ CalcEngine::Rational CCalcEngine::DoOperation(int operation, CalcEngine::Rationa
result = Root(rhs, result); result = Root(rhs, result);
break; break;
case IDC_LOGBASEX: case IDC_LOGBASEY:
result = (Log(result) / Log(rhs)); result = (Log(rhs) / Log(result));
break; break;
} }
} }

View file

@ -172,7 +172,7 @@ namespace CalculationManager
CommandCeil = 415, CommandCeil = 415,
CommandROLC = 416, CommandROLC = 416,
CommandRORC = 417, CommandRORC = 417,
CommandLogBaseX = 500, CommandLogBaseY = 500,
CommandNand = 501, CommandNand = 501,
CommandNor = 502, CommandNor = 502,

View file

@ -166,7 +166,7 @@
#define IDC_LASTCONTROL IDC_CEIL #define IDC_LASTCONTROL IDC_CEIL
#define IDC_BINARYEXTENDEDFIRST 500 #define IDC_BINARYEXTENDEDFIRST 500
#define IDC_LOGBASEX 500 // logx(y) #define IDC_LOGBASEY 500 // logy(x)
#define IDC_NAND 501 // Nand #define IDC_NAND 501 // Nand
#define IDC_NOR 502 // Nor #define IDC_NOR 502 // Nor

View file

@ -196,7 +196,7 @@ inline constexpr auto SIDS_ACSCH = L"InverseCsch";
inline constexpr auto SIDS_COTH = L"Coth"; inline constexpr auto SIDS_COTH = L"Coth";
inline constexpr auto SIDS_ACOTH = L"InverseCoth"; inline constexpr auto SIDS_ACOTH = L"InverseCoth";
inline constexpr auto SIDS_TWOPOWX = L"TwoPowX"; inline constexpr auto SIDS_TWOPOWX = L"TwoPowX";
inline constexpr auto SIDS_LOGBASEX = L"LogBaseX"; inline constexpr auto SIDS_LOGBASEY = L"LogBaseY";
inline constexpr auto SIDS_ABS = L"Abs"; inline constexpr auto SIDS_ABS = L"Abs";
inline constexpr auto SIDS_FLOOR = L"Floor"; inline constexpr auto SIDS_FLOOR = L"Floor";
inline constexpr auto SIDS_CEIL = L"Ceil"; inline constexpr auto SIDS_CEIL = L"Ceil";
@ -352,7 +352,7 @@ inline constexpr std::array<std::wstring_view, 152> g_sids =
SIDS_COTH, SIDS_COTH,
SIDS_ACOTH, SIDS_ACOTH,
SIDS_TWOPOWX, SIDS_TWOPOWX,
SIDS_LOGBASEX, SIDS_LOGBASEY,
SIDS_ABS, SIDS_ABS,
SIDS_FLOOR, SIDS_FLOOR,
SIDS_CEIL, SIDS_CEIL,

View file

@ -109,7 +109,7 @@ public
InvCoth = (int) CM::Command::CommandACOTH, InvCoth = (int) CM::Command::CommandACOTH,
CubeRoot = (int) CM::Command::CommandCUBEROOT, CubeRoot = (int) CM::Command::CommandCUBEROOT,
TwoPowerX = (int) CM::Command::CommandPOW2, TwoPowerX = (int) CM::Command::CommandPOW2,
LogBaseX = (int) CM::Command::CommandLogBaseX, LogBaseY = (int) CM::Command::CommandLogBaseY,
Nand = (int) CM::Command::CommandNand, Nand = (int) CM::Command::CommandNand,
Nor = (int) CM::Command::CommandNor, Nor = (int) CM::Command::CommandNor,
Abs = (int) CM::Command::CommandAbs, Abs = (int) CM::Command::CommandAbs,

View file

@ -545,7 +545,7 @@ unordered_map<wstring, wstring> LocalizationService::GetTokenToReadableNameMap()
static vector<pair<wstring, wstring>> s_noParenEngineKeyResourceMap = { // Programmer mode functions static vector<pair<wstring, wstring>> s_noParenEngineKeyResourceMap = { // Programmer mode functions
make_pair<wstring, wstring>(L"9", L"LeftShift"), make_pair<wstring, wstring>(L"9", L"LeftShift"),
make_pair<wstring, wstring>(L"10", L"RightShift"), make_pair<wstring, wstring>(L"10", L"RightShift"),
make_pair<wstring, wstring>(L"LogBaseX", L"Logx"), make_pair<wstring, wstring>(L"LogBaseY", L"Logy"),
// Y Root scientific function // Y Root scientific function
make_pair<wstring, wstring>(L"16", L"YRoot") make_pair<wstring, wstring>(L"16", L"YRoot")

View file

@ -517,8 +517,8 @@
<value>2^</value> <value>2^</value>
<comment>{Locked}The string that represents the function</comment> <comment>{Locked}The string that represents the function</comment>
</data> </data>
<data name="LogBaseX" xml:space="preserve"> <data name="LogBaseY" xml:space="preserve">
<value>base log</value> <value>log base</value>
<comment>{Locked}The string that represents the function</comment> <comment>{Locked}The string that represents the function</comment>
</data> </data>
<data name="Abs" xml:space="preserve"> <data name="Abs" xml:space="preserve">

View file

@ -3447,9 +3447,9 @@
<value>Cube Root</value> <value>Cube Root</value>
<comment>Name for the cube root function. Used by screen readers.</comment> <comment>Name for the cube root function. Used by screen readers.</comment>
</data> </data>
<data name="Logx" xml:space="preserve"> <data name="Logy" xml:space="preserve">
<value>Base Log</value> <value>Log Base</value>
<comment>Name for the logbasex function. Used by screen readers.</comment> <comment>Name for the logbasey function. Used by screen readers.</comment>
</data> </data>
<data name="AbsoluteValue" xml:space="preserve"> <data name="AbsoluteValue" xml:space="preserve">
<value>Absolute Value</value> <value>Absolute Value</value>
@ -3519,11 +3519,11 @@
<value>Calculation failed</value> <value>Calculation failed</value>
<comment>Text displayed when the application is not able to do a calculation</comment> <comment>Text displayed when the application is not able to do a calculation</comment>
</data> </data>
<data name="logBaseX.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve"> <data name="logBaseY.[using:Windows.UI.Xaml.Automation]AutomationProperties.Name" xml:space="preserve">
<value>Log base X</value> <value>Log base Y</value>
<comment>Screen reader prompt for the logBaseX button</comment> <comment>Screen reader prompt for the logBaseY button</comment>
</data> </data>
<data name="logBaseX.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve"> <data name="logBaseY.[using:CalculatorApp.Common]KeyboardShortcutManager.VirtualKeyShiftChord" xml:space="preserve">
<value>L</value> <value>L</value>
<comment>{Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum.</comment> <comment>{Locked}This is the character that should trigger this button. Note that it is a character and not a key, so it does not come from the Windows::System::VirtualKey enum.</comment>
</data> </data>

View file

@ -90,7 +90,7 @@
<Setter Target="FuncButton.IsEnabled" Value="False"/> <Setter Target="FuncButton.IsEnabled" Value="False"/>
<Setter Target="EulerButton.IsEnabled" Value="False"/> <Setter Target="EulerButton.IsEnabled" Value="False"/>
<Setter Target="AbsButton.IsEnabled" Value="False"/> <Setter Target="AbsButton.IsEnabled" Value="False"/>
<Setter Target="LogBaseX.IsEnabled" Value="False"/> <Setter Target="LogBaseY.IsEnabled" Value="False"/>
<Setter Target="TwoPowerXButton.IsEnabled" Value="False"/> <Setter Target="TwoPowerXButton.IsEnabled" Value="False"/>
<Setter Target="CubeRootButton.IsEnabled" Value="False"/> <Setter Target="CubeRootButton.IsEnabled" Value="False"/>
</VisualState.Setters> </VisualState.Setters>
@ -148,7 +148,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="LogBaseY.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
@ -238,7 +238,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="LogBaseY.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
@ -326,7 +326,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="16"/> <Setter Target="LogBaseY.FontSize" Value="16"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
@ -1039,12 +1039,12 @@
Click="ShiftButton_Uncheck" Click="ShiftButton_Uncheck"
Content="&#xF882;"/> Content="&#xF882;"/>
<controls:CalculatorButton x:Name="LogBaseX" <controls:CalculatorButton x:Name="LogBaseY"
x:Uid="logBaseX" x:Uid="logBaseY"
Grid.Row="4" Grid.Row="4"
Style="{StaticResource EmphasizedCalcButtonStyle}" Style="{StaticResource EmphasizedCalcButtonStyle}"
AutomationProperties.AutomationId="logBaseX" AutomationProperties.AutomationId="logBaseY"
ButtonId="LogBaseX" ButtonId="LogBaseY"
Click="ShiftButton_Uncheck" Click="ShiftButton_Uncheck"
Content="&#xF883;"/> Content="&#xF883;"/>

View file

@ -80,7 +80,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="LogBaseY.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcButtonCaptionSize}"/>
@ -185,7 +185,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="LogBaseY.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcStandardOperatorCaptionSize}"/>
@ -288,7 +288,7 @@
<Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="EulerButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="AbsButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="LogBaseX.FontSize" Value="16"/> <Setter Target="LogBaseY.FontSize" Value="16"/>
<Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="TwoPowerXButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
<Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/> <Setter Target="CubeRootButton.FontSize" Value="{ThemeResource CalcOperatorCaptionSize}"/>
@ -1049,12 +1049,12 @@
Content="&#xF882;" Content="&#xF882;"
IsTabStop="false"/> IsTabStop="false"/>
<controls:CalculatorButton x:Name="LogBaseX" <controls:CalculatorButton x:Name="LogBaseY"
x:Uid="logBaseX" x:Uid="logBaseY"
Grid.Row="4" Grid.Row="4"
Style="{StaticResource EmphasizedCalcButtonStyle}" Style="{StaticResource EmphasizedCalcButtonStyle}"
AutomationProperties.AutomationId="logBaseX" AutomationProperties.AutomationId="logBaseY"
ButtonId="LogBaseX" ButtonId="LogBaseY"
Click="ShiftButton_Uncheck" Click="ShiftButton_Uncheck"
Content="&#xF883;" Content="&#xF883;"
IsTabStop="false"/> IsTabStop="false"/>

View file

@ -63,7 +63,7 @@ static const std::unordered_map<NumbersAndOperatorsEnum, std::tuple<Platform::St
{ NumbersAndOperatorsEnum::CubeRoot, { L"cbrt()", 5, 0 } }, { NumbersAndOperatorsEnum::CubeRoot, { L"cbrt()", 5, 0 } },
{ NumbersAndOperatorsEnum::YRootX, { L"root(x" + StringReference(LocalizationSettings::GetInstance().GetListSeparator().data()) + L"n)", 7, 1 } }, { NumbersAndOperatorsEnum::YRootX, { L"root(x" + StringReference(LocalizationSettings::GetInstance().GetListSeparator().data()) + L"n)", 7, 1 } },
{ NumbersAndOperatorsEnum::TwoPowerX, { L"2^", 2, 0 } }, { NumbersAndOperatorsEnum::TwoPowerX, { L"2^", 2, 0 } },
{ NumbersAndOperatorsEnum::LogBaseX, { "log(b" + StringReference(LocalizationSettings::GetInstance().GetListSeparator().data()) + L" x)", 4, 1 } }, { NumbersAndOperatorsEnum::LogBaseY, { "log(b" + StringReference(LocalizationSettings::GetInstance().GetListSeparator().data()) + L" x)", 4, 1 } },
{ NumbersAndOperatorsEnum::EPowerX, { L"e^", 4, 0 } }, { NumbersAndOperatorsEnum::EPowerX, { L"e^", 4, 0 } },
{ NumbersAndOperatorsEnum::Abs, { L"abs()", 4, 0 } }, { NumbersAndOperatorsEnum::Abs, { L"abs()", 4, 0 } },
{ NumbersAndOperatorsEnum::X, { L"x", 1, 0 } }, { NumbersAndOperatorsEnum::X, { L"x", 1, 0 } },

View file

@ -613,8 +613,8 @@ namespace CalculatorManagerTest
Command commands41[] = { Command::Command3, Command::CommandPNT, Command::Command8, Command::CommandCeil, Command::CommandNULL }; Command commands41[] = { Command::Command3, Command::CommandPNT, Command::Command8, Command::CommandCeil, Command::CommandNULL };
TestDriver::Test(L"4", L"ceil(3.8)", commands41); TestDriver::Test(L"4", L"ceil(3.8)", commands41);
Command commands42[] = { Command::Command3, Command::CommandLogBaseX, Command::Command5, Command::CommandADD, Command::CommandNULL }; Command commands42[] = { Command::Command5, Command::CommandLogBaseY, Command::Command3, Command::CommandADD, Command::CommandNULL };
TestDriver::Test(L"1.464973520717927", L"3 base log 5 + ", commands42); TestDriver::Test(L"1.464973520717927", L"5 log base 3 + ", commands42);
} }
void CalculatorManagerTest::CalculatorManagerTestScientificParenthesis() void CalculatorManagerTest::CalculatorManagerTestScientificParenthesis()