7 public static Bit and(Bit a, Bit b)
12 public Bit and(Bit other)
14 if (equals(Bit.ZERO) || other.equals(Bit.ZERO))
16 else if (equals(other) && equals(Bit.ONE))
22 public static Bit or(Bit a, Bit b)
27 public Bit or(Bit other)
29 if (equals(Bit.ONE) || other.equals(Bit.ONE))
31 else if (equals(other) && equals(Bit.ZERO))
37 public static Bit xor(Bit a, Bit b)
42 public Bit xor(Bit other)
44 // I'm uncertain how this should behave for cases where one value is neither 1 nor 0.
45 // TODO: Implement xor
63 * Rules for two bits that get directly connected<br>
66 * <tr><td><td>X<td>0<td>1<td>Z</tr>
67 * <tr><td>X<td>X<td>X<td>X<td>X</tr>
68 * <tr><td>0<td>X<td>0<td>X<td>0</tr>
69 * <tr><td>1<td>X<td>X<td>1<td>1</tr>
70 * <tr><td>Z<td>X<td>0<td>1<td>Z</tr>
74 * @return the result according to the table
76 * @author Christian Femers
78 public Bit combineWith(Bit other)
82 if (this == X || other == X)
91 public static Bit combine(Bit a, Bit b)
93 return a.combineWith(b);