[gnome-calculator] Error on calculating undefined atan(+/-i) (fixes #139)



commit b497b92cf6c905b04da4c0c4f9dd57183b6ccfe1
Author: Robert Roth <robert roth off gmail com>
Date:   Fri Jan 31 21:47:48 2020 +0200

    Error on calculating undefined atan(+/-i) (fixes #139)

 lib/number.vala | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/lib/number.vala b/lib/number.vala
index b36b7373..c8f58755 100644
--- a/lib/number.vala
+++ b/lib/number.vala
@@ -712,6 +712,13 @@ public class Number : Object
     /* Sets z = tan⁻¹ x */
     public Number atan (AngleUnit unit = AngleUnit.RADIANS)
     {
+        /* Check x != i and x != -i */
+        if (equals (new Number.integer (0,1)) || equals (new Number.integer(0,-1)))
+        {
+            /* Translators: Error displayed when trying to calculate undefined atan(i) or atan (-i) */
+            error = _("Arctangent function is undefined for values i and -i");
+            return new Number.integer (0);
+        }
         var z = new Number ();
         z.num.atan (num);
         if (!z.is_complex ())


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]