Fix the comparaison when a comparing a Double and a complex Double 42/1442/2
Sylvestre Ledru [Tue, 29 Jun 2010 13:50:42 +0000 (15:50 +0200)]
Change-Id: I450bc86afbb8b5cff736dbd6f8e2772d584628ff

scilab/modules/types/src/java/org/scilab/modules/types/scilabTypes/ScilabDouble.java

index c316e27..706d12d 100644 (file)
@@ -159,11 +159,12 @@ public class ScilabDouble implements ScilabType {
      */
     public boolean equals(Object obj) {
         if (obj instanceof ScilabDouble) {
-            if (this.isReal()) {
-                return Arrays.deepEquals(this.getRealPart(), ((ScilabDouble)obj).getRealPart());
+            ScilabDouble sciDouble = ((ScilabDouble)obj);
+            if (this.isReal() && sciDouble.isReal()) {
+                return Arrays.deepEquals(this.getRealPart(), sciDouble.getRealPart());
             } else {
                 /* Complex */
-                return Arrays.deepEquals(this.getRealPart(), ((ScilabDouble)obj).getRealPart()) && Arrays.deepEquals(this.getImaginaryPart(), ((ScilabDouble)obj).getImaginaryPart());
+                return Arrays.deepEquals(this.getRealPart(), sciDouble.getRealPart()) && Arrays.deepEquals(this.getImaginaryPart(), sciDouble.getImaginaryPart());
             }
         } else {
             return false;