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