/** from nowjava - 时代Java**/
//package com.nowjava;
public class Main {
public static void main(String[] argv) throws Exception {
int num = 2;
System.out.println(to6BitBinary(num));
}
/**
* Convert an integer into a six bit binary string.
*
* @param num The int to convert.
*
* @return A six character string that represents the int.
*/
public static String to6BitBinary(int num) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 6; i++) {
sb.append(((num & 1) == 1) ? '1' : '0');
num >>= 1;
}
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。