List of utility methods to do Integer to Binary
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; |
int | ItoB(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; |
String | itob(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(); ... |