Java Utililty Methods Bit Print

List of utility methods to do Bit Print

Description

The list of methods to do Bit Print are organized into topic(s).

Method

StringprintBitBinary(byte[] bytes)
Transform bite array to bit representation
StringBuilder sb = new StringBuilder();
for (byte b : bytes) {
    String s = Integer.toBinaryString((b & 0xFF) + 0x100).substring(1);
    if (sb.length() > 0) {
        sb.append(" ");
    if (s.length() > 4) {
        sb.append(s.substring(0, 4)).append(" ").append(s.substring(4, s.length()));
...
voidprintBitboard(long bitboard)
Prints a bitboard by sending the result of bitboardToString to System.out.
System.out.println(bitboardToString(bitboard));
voidprintBitFormat(int number)
print Bit Format
for (int idx = INT_SIZE - 1; idx >= 0; --idx) {
    if ((number & (1 << idx)) == 0) {
        System.out.print("0");
    } else {
        System.out.print("1");
System.out.println();
...
voidprintBitLong(long A)
print Bit Long
System.out.println(toPadString(A));
voidprintBits(byte[] bytes)
print Bits
boolean firstFlag = true;
StringBuffer logBuffer = new StringBuffer();
String b = "";
for (byte i : bytes) {
    b = Integer.toHexString(i & 0xff);
    b = (b.length() == 1 ? ("0" + b) : b);
    if (firstFlag) {
        logBuffer.append("[" + b);
...
voidprintBits(int meta)
print Bits
for (int k = 0; k < 4; k++) {
    if (((meta >> k) & 1) == 1) {
        System.out.print(1);
    } else {
        System.out.print(0);
System.out.println();
...
StringprintBits(int number, int n)
print Bits
String s = "";
for (int i = 0; i < n; i++) {
    s += getBit(number, i) ? "1" : "0";
return s;
voidprintBits(long val, int bits)
print Bits
while (bits-- != 0) {
    System.out.print(((val >>> bits) & 1) != 0 ? '1' : '0');
StringprintBits(long value)
Print the bits in the value with the leftmost bit being the most significant bit.
StringBuffer sb = new StringBuffer();
for (int shift = 63; shift >= 0; shift--)
    sb.append((((value >>> shift) & 01) != 0) ? "1" : "0");
return sb.toString();