/**
* 将十进制转成二进制(注意不能转负数)
* @param num
* @return String
*/
public static String toBinary(Integer num) {
StringBuilder sb = new StringBuilder();
while(num != 0) {
sb.append(num % 2);
num = num / 2;
}
return sb.reverse().toString();
}
/**
* 将十进制转成二进制(注意不能转负数)
* @param num
* @return String
*/
public static String toBinary(Integer num) {
StringBuilder sb = new StringBuilder();
while(num != 0) {
sb.append(num % 2);
num = num / 2;
}
return sb.reverse().toString();
}