Java Bit Get bits(int value, int c)

Here you can find the source of bits(int value, int c)

Description

bits

License

Open Source License

Declaration

public final static String bits(int value, int c) 

Method Source Code

//package com.java2s;
/** //from w  w  w .ja va  2  s .co  m
 * Copyright (c) 2003-2007 Stewart Allen <stewart@neuron.com>. All rights reserved.
 * This program is free software. See the 'License' file for details.
 */

public class Main {
    public final static String bits(int value, int c) {
        StringBuffer sb = new StringBuffer();
        for (int i = c - 1; i >= 0; i--) {
            int bv = (value >>> (8 * i)) & 0xff;
            sb.append('[');
            for (int j = 7; j >= 0; j--) {
                sb.append((bv & (1 << j)) > 0 ? '1' : '0');
            }
            sb.append(']');
        }
        return sb.toString();
    }
}

Related

  1. bitAt(int offset, byte aByte)
  2. bitAt(int offset, byte aByte)
  3. bits(int i)
  4. bits(int i)
  5. bits(int n, int offset, int length)
  6. bits(int value, int first, int last)
  7. bits(long maxValue)
  8. bits(long value, int sb, int eb)