// 十进制转换二进制 private static String convertBinary(int sum) { StringBuffer binary = new StringBuffer(); while (sum != 0 && sum != 1) { binary.insert(0, sum % 2); sum = sum / 2; if (sum == 0 || sum == 1) { binary.insert(0, sum % 2); } } return binary.toString(); }
时间: 2024-10-20 02:09:21