Java Utililty Methods Integer to Binary

List of utility methods to do Integer to Binary

Description

The list of methods to do Integer to Binary are organized into topic(s).

Method

byte[]itob(int i, int j)
Creates a byte representation of the first argument
byte[] res = new byte[j];
for (int n = j - 1; n >= 0; n--) {
    res[n] = (byte) ('0' + (i % 10));
    i = i / 10;
return res;
intItoB(int x)
Ito B
return (x & 0x000000ff);
byte[]iToB(int[] intVals)
i To B
byte[] byteVals = new byte[intVals.length];
for (int i = 0; i < byteVals.length; i++) {
    byteVals[i] = (byte) intVals[i];
return byteVals;
Stringitob(long integer, int[] arr)
Converts a binary number, the number required, and the number of bits desired output (here 26) Store the result in the overall picture "bit2"
for (int i = 0; i < arr.length; i++) {
    if ((integer / power2(arr.length - 1 - i)) == 1) {
        integer -= power2(arr.length - 1 - i);
        arr[i] = 1;
    } else
        arr[i] = 0;
StringBuilder sb = new StringBuilder();
...