50,523
社区成员
发帖
与我相关
我的任务
分享
for (int i = 31; i >= 0; i--) {
System.out.print(((x & (1 << i)) >>> i) + " ");
}
for (int i = 31; i >= 0; i--) {
System.out.print(((x >>> i) & 1) + " ");
}
public static void main(String[] args) {
int n = -3;
char[] chs = new char[Integer.SIZE];
for (int i = 0, p = i - 1; i < chs.length; i++, p--) {
chs[i] = (char)('0' + ((n >> p) & 1));
}
System.out.println(new String(chs));
}