diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/QueryTests.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/QueryTests.cs
index 2c3896cde66b..e61719842add 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/QueryTests.cs
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator.UnitTest/QueryTests.cs
@@ -37,6 +37,7 @@ public void Initialize()
[DataRow("=2^96", "Result value was either too large or too small for a decimal number")]
[DataRow("=+()", "Calculation result is not a valid number (NaN)")]
[DataRow("=[10,10]", "Unsupported use of square brackets")]
+ [DataRow("=sqrt(-1)", "Complex numbers are not supported")]
[DataRow("=5/0", "Expression contains division by zero")]
[DataRow("=5 / 0", "Expression contains division by zero")]
[DataRow("10+(8*9)/0+7", "Expression contains division by zero")]
@@ -63,6 +64,7 @@ public void ErrorResultOnInvalidKeywordQuery(string typedString, string expected
[DataRow("2^96")]
[DataRow("+()")]
[DataRow("[10,10]")]
+ [DataRow("sqrt(-1)")]
[DataRow("5/0")]
[DataRow("5 / 0")]
[DataRow("10+(8*9)/0+7")]
diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateEngine.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateEngine.cs
index f44a72676c7b..a4c7b3025044 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateEngine.cs
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/CalculateEngine.cs
@@ -5,6 +5,7 @@
using System;
using System.Collections.Generic;
using System.Globalization;
+using System.Numerics;
using System.Text.RegularExpressions;
using Mages.Core;
@@ -122,6 +123,11 @@ private static dynamic TransformResult(object result)
return Properties.Resources.wox_plugin_calculator_double_array_returned;
}
+ if (result is Complex)
+ {
+ return Properties.Resources.wox_plugin_calculator_complex_number_returned;
+ }
+
return result;
}
diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
index 861993dbdd33..bb7efc291aba 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.Designer.cs
@@ -68,6 +68,15 @@ public static string wox_plugin_calculator_calculation_failed {
return ResourceManager.GetString("wox_plugin_calculator_calculation_failed", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Complex numbers are not supported.
+ ///
+ public static string wox_plugin_calculator_complex_number_returned {
+ get {
+ return ResourceManager.GetString("wox_plugin_calculator_complex_number_returned", resourceCulture);
+ }
+ }
///
/// Looks up a localized string similar to Copy failed, please try later.
diff --git a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.resx b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.resx
index 3c56eedf4b5d..7f913084d2d1 100644
--- a/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.resx
+++ b/src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.Calculator/Properties/Resources.resx
@@ -141,6 +141,9 @@
Unsupported use of square brackets
+
+ Complex numbers are not supported
+
Result value was either too large or too small for a decimal number
@@ -187,4 +190,4 @@
Gradians
Text for angle unit.
-
\ No newline at end of file
+