[gnome-calculator/gnome-3-18] Check if base or exponent are complex for xpowy() method
- From: Alberto Ruiz <aruiz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calculator/gnome-3-18] Check if base or exponent are complex for xpowy() method
- Date: Mon, 28 Dec 2015 16:18:28 +0000 (UTC)
commit f5357f39b2ba663f1c01a83c4981271e48c8da90
Author: Alberto Ruiz <aruiz gnome org>
Date: Mon Dec 28 16:12:32 2015 +0000
Check if base or exponent are complex for xpowy() method
Fixes #757657
lib/number.vala | 6 ++++++
tests/test-equation.vala | 2 ++
2 files changed, 8 insertions(+), 0 deletions(-)
---
diff --git a/lib/number.vala b/lib/number.vala
index 8f94a40..0b09248 100644
--- a/lib/number.vala
+++ b/lib/number.vala
@@ -498,6 +498,12 @@ public class Number : Object
return new Number.integer (0);
}
+ /* base or exponent are complex */
+ if (is_complex () || y.is_complex ())
+ {
+ return pwr (y);
+ }
+
if (!y.is_integer ())
{
var reciprocal = y.reciprocal ();
diff --git a/tests/test-equation.vala b/tests/test-equation.vala
index b5d46d4..80b3898 100644
--- a/tests/test-equation.vala
+++ b/tests/test-equation.vala
@@ -560,6 +560,8 @@ private void test_equations ()
test ("i×i", "−1", 0);
test ("i÷i", "1", 0);
test ("1÷i", "−i", 0);
+ test ("i^2", "−1", 0);
+ test ("(−1)^(1/2)", "i", 0);
test ("|i|", "1", 0);
test ("|3+4i|", "5", 0);
test ("arg 0", "", ErrorCode.MP);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]