using System;
public class HelloWorld
{
public static void Main()
{
Console.WriteLine("-------& | ^ ~ 各类位运算-----------");
int a = 4,b = 6;
Console.WriteLine("a & b = " + (a & b));
Console.WriteLine("a | b = " + (a | b));
Console.WriteLine("a ^ b = " + (a ^ b));
Console.WriteLine("~a = " + ~a);
Console.WriteLine("~b = " + ~b);
Console.WriteLine("---------左移与右移位运算----------");
int A = 13;
A = A << 2;
Console.WriteLine("当前A的数值为: " + A);
int B = 2;
Console.WriteLine("B << 2 = " + (B << 2));
Console.WriteLine("B >> 2 = " + (B >> 2));
Console.WriteLine("--------左移右移练习题---------");
const int Num = 13;
Console.WriteLine("提取Num的低一位数值为:" + (Num & 1));
Console.WriteLine("提取Num的低二位数值为:" + (Num >> 1 & 1));
Console.WriteLine("提取Num的第三位数值为:" + (Num >> 2 & 1));
}
}