1 package net.mograsim.logic.ui.am2900;
\r
3 public final class TestUtil
\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
13 public static String to4bitBin(int x)
\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