List of utility methods to do Decimal to Binary
String | dec2bin(int dec) decbin if (0 == dec) return "0"; StringBuffer sb = new StringBuffer(); while (dec != 0) { sb.append(1 == dec % 2 ? 1 : 0); dec >>= 1; return sb.reverse().toString(); ... |
String | dec2bin(Integer str) decbin String num = Integer.toBinaryString(str);
return num;
|
String | decimalToBinaryString(int n) decimal To Binary String return Integer.toBinaryString(n);
|
String | decimalToBitString(int n, int min, int max) decimal To Bit String max -= min; n -= min; if (max == 0 || n < 0 || n > max) { return ""; int biggestPower = (int) logBaseN(max + 1, 2); int maxInBiggestPower = (int) Math.pow(2, biggestPower); if (n < maxInBiggestPower) { ... |