ajusted or() behaviour when Z is input
authorChristian Femers <femers@in.tum.de>
Tue, 14 May 2019 12:20:23 +0000 (14:20 +0200)
committerChristian Femers <femers@in.tum.de>
Tue, 14 May 2019 12:20:23 +0000 (14:20 +0200)
era.mi/src/era/mi/logic/Bit.java

index 58a538a..3f25d77 100644 (file)
@@ -13,12 +13,14 @@ public enum Bit
 \r
        public Bit and(Bit other)\r
        {\r
-               if (equals(Bit.ZERO) || other.equals(Bit.ZERO))\r
-                       return Bit.ZERO;\r
-               else if (equals(other) && equals(Bit.ONE))\r
-                       return Bit.ONE;\r
+               if (this == ZERO || other == ZERO)\r
+                       return ZERO;\r
+               else if (this == other && this == ONE)\r
+                       return ONE;\r
+               else if (this == X || other == X)\r
+                       return X;\r
                else\r
-                       return Bit.X;\r
+                       return ZERO;\r
        }\r
 \r
        public static Bit or(Bit a, Bit b)\r
@@ -28,12 +30,14 @@ public enum Bit
 \r
        public Bit or(Bit other)\r
        {\r
-               if (equals(Bit.ONE) || other.equals(Bit.ONE))\r
-                       return Bit.ONE;\r
-               else if (equals(other) && equals(Bit.ZERO))\r
-                       return Bit.ZERO;\r
+               if (this == ONE || other == ONE)\r
+                       return ONE;\r
+               else if (this == other && this == ZERO)\r
+                       return ZERO;\r
+               else if (this == X || other == X)\r
+                       return X;\r
                else\r
-                       return Bit.X;\r
+                       return ZERO;\r
        }\r
 \r
        public static Bit xor(Bit a, Bit b)\r
@@ -43,11 +47,10 @@ public enum Bit
 \r
        public Bit xor(Bit other)\r
        {\r
-               if(this == Bit.X || this == Bit.Z\r
-                               || other == Bit.X || other == Bit.Z)\r
+               if(this == X || this == Z || other == X || other == Z)\r
                        return Bit.X;\r
                else\r
-                       return this == other ? Bit.ZERO : Bit.ONE;\r
+                       return this == other ? ZERO : ONE;\r
        }\r
 \r
        public Bit not()\r