diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs index 82a5b83a61..929fa8489a 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/ExtendedCalculatorParserTests.cs @@ -74,6 +74,8 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests new object[] { "e*2", 5.43656365691809M }, new object[] { "ln(3)", 1.09861228866810M }, new object[] { "log(3)", 0.47712125471966M }, + new object[] { "log2(3)", 1.58496250072116M }, + new object[] { "log10(3)", 0.47712125471966M }, new object[] { "ln(e)", 1M }, new object[] { "cosh(0)", 1M }, }; @@ -166,6 +168,10 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator.UnitTests [DataTestMethod] [DataRow("log(3)", true)] [DataRow("ln(3)", true)] + [DataRow("log2(3)", true)] + [DataRow("log10(3)", true)] + [DataRow("log2", false)] + [DataRow("log10", false)] [DataRow("log", false)] [DataRow("ln", false)] [DataRow("ceil(2 * (pi ^ 2))", true)] diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs index ca00f679d3..d0908b3de0 100644 --- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs +++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateHelper.cs @@ -12,7 +12,7 @@ namespace Microsoft.PowerToys.Run.Plugin.Calculator private static readonly Regex RegValidExpressChar = new Regex( @"^(" + @"%|" + - @"ceil\s*\(|floor\s*\(|exp\s*\(|max\s*\(|min\s*\(|abs\s*\(|log\s*\(|ln\s*\(|sqrt\s*\(|pow\s*\(|" + + @"ceil\s*\(|floor\s*\(|exp\s*\(|max\s*\(|min\s*\(|abs\s*\(|log(?:2|10)?\s*\(|ln\s*\(|sqrt\s*\(|pow\s*\(|" + @"factorial\s*\(|sign\s*\(|round\s*\(|rand\s*\(|" + @"sin\s*\(|cos\s*\(|tan\s*\(|arcsin\s*\(|arccos\s*\(|arctan\s*\(|" + @"sinh\s*\(|cosh\s*\(|tanh\s*\(|arsinh\s*\(|arcosh\s*\(|artanh\s*\(|" +