Java Binary Encode toBinary(long v, int len)

Here you can find the source of toBinary(long v, int len)

Description

to Binary

License

Open Source License

Declaration

public static char[] toBinary(long v, int len) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {

    public static char[] toBinary(long v, int len) {
        char[] cs = new char[len];
        for (int i = 0; i < len; i++) {
            cs[i] = (v >> (len - i - 1) & 1) != 0 ? '1' : '0';
        }/*w  w  w.j a  v  a 2  s.  c o  m*/
        return cs;
    }
}

Related

  1. toBinary(int nr, int bits)
  2. toBinary(int number, int length)
  3. toBinary(int val)
  4. toBinary(int value, int bits)
  5. toBinary(long l, int bits)
  6. toBinary(short value)
  7. toBinaryAddress(int index, int maxIndex)
  8. toBinaryArray(int input, int length)
  9. toBinaryArray(int integer, int size)