package C1;
public class Test {
public static void main(String[] args) {
int num=86;
System.out.println(num+"num是:"+(((num&1)==0)?"偶数":"奇数"));
System.out.println("=====获取二进制位是0或1======");
System.out.println(num+"的第5位二进制数是:"+((((num&(1<<4))>>4)==0)?"0":"1"));
System.out.println(num+"的第5位二进制数是:"+((((num>>4)&1)==0)?"0":"1"));
System.out.println("=========变量表换========");
int num1=10;
int num2=20;
num1=num1^num2;
num2=num1^num2;
num1=num1^num2;
System.out.println("num1=="+num1+", num2=="+num2);
System.out.println("======求整数的绝对值======");
int num3=-50;
System.out.println(num3+"num3的绝对值是"+((num3^(num3>>31))+(num3>>>31)));
}
}
|