10-》2
private void pBinInt(String s, int i) {
System.out.println(
s + ", int: " + i + ", binary: ");
System.out.print(" ");
for(int j = 31; j >=0; j--) //代码A
{
if(((1 << j) & i) != 0)
System.out.print("1");
else
System.out.print("0"); //代码B
System.out.println("1<<j="+(1 << j));
}
System.out.println();
}
private void pBinInt(String s, int i) {
System.out.println(
s + ", int: " + i + ", binary: ");
System.out.print(" ");
for(int j = 31; j >=0; j--) //代码A
{
if(((1 << j) & i) != 0)
System.out.print("1");
else
System.out.print("0"); //代码B
System.out.println("1<<j="+(1 << j));
}
System.out.println();
}
解决方案 »
- 关于dom4j查询xml 建web project没事 建java project运行就会出错
- Connection reset 问题
- 应届生何去何从..(混csdn多年,第一次发帖,请多多包含,帮顶)
- 用java写的操作系统NRU页面置换算法,模拟实现NRU过程,有错误,NULLPointerException,求指点
- try,catch,fially经典在这里
- 请问各位高手:编码为"B5 C8 30 41 BF BC 8C 9A",问这串编码中包含有( )个汉字?
- vector要进行范围检查嘛?
- 关于j2se开发桌面应用程序
- 奇怪的java问题
- 是不是java写的应用程序比其他的编程语言写的应用程序在windows上运行的慢?
- 关于父类跟子类之间的转换问题,能人请进...
- 几个小问题(100)分
String s1 = Integer.toBinaryString(i);
String s2 = Integer.toHexString(i);
String s3 = Integer.toOctalString(i);
byte b = Byte.parseByte("1011", 2); // 二进位的 1011 , 在十进位中则是 11
short sh = Short.parseShort("ff", 16); // 十六进位的 ff , 在十进位中为 255 // valueOf() 方法可以处理任意的基底(base)
int i = Integer.valueOf("egg", 17).intValue(); // 以 17 为基底 // decode() 方法可以处理八进位、十进位或十六进位
// 要看该字串前面的数字为何
short sh = Short.decode("0377").byteValue(); // 以 0 开头表示是八进位
int i = Integer.decode("0xff").shortValue(); // 以 0x 开头表示是十六进位
long l = Long.decode("255").intValue(); // 其他的数字则表示是十进位 // 能将数字转换为字串的 Integer 类别
String decimal = Integer.toString(42);
String binary = Integer.toBinaryString(42);
String octal = Integer.toOctalString(42);
String hex = Integer.toHexString(42);
String base36 = Integer.toString(42, 36);