&,|,^的用法
- &按位与
- |按位或
- ^按位异或
举例: int x = 5; int y = 11;
System.out.println(x|y); System.out.println(x&y); System.out.println(x^y);
结果是15, 1 ,14
分析:
x=5 (0101二进制)
y=11(1011二进制)
x&y = 0001 = 1
x|y = 1111 = 15
x^y = 1110 = 14
^的运用与性质
原文地址:https://www.cnblogs.com/lijingran/p/8854986.html
时间: 2024-10-23 09:55:25