Completely changed the structure and switched to Eclipse Plugin.
[Mograsim.git] / net.mograsim.logic.ui.am2900 / test / net / mograsim / logic / ui / am2900 / TestUtil.java
1 package net.mograsim.logic.ui.am2900;\r
2 \r
3 public final class TestUtil\r
4 {\r
5         private TestUtil()\r
6         {\r
7 \r
8         }\r
9 \r
10         /**\r
11          * Transforms the last four bits of an int to a string that contains the binary ('1' and '0') representation of the 4 bits\r
12          */\r
13         public static String to4bitBin(int x)\r
14         {\r
15                 StringBuilder sb = new StringBuilder(4);\r
16                 sb.append((x & 0b1000) == 0 ? '0' : '1');\r
17                 sb.append((x & 0b0100) == 0 ? '0' : '1');\r
18                 sb.append((x & 0b0010) == 0 ? '0' : '1');\r
19                 sb.append((x & 0b0001) == 0 ? '0' : '1');\r
20                 return sb.toString();\r
21         }\r
22 }\r