主题:哪位大哥帮帮忙啊
这是一个C#.NET的控制台应用程序
using System;
class MyClass
{
public static void Main()
{
int varA = 10; //二进制为 00001010
int varB = 20; //二进制为 00010100
// “与”运算
int andResult = varA & varB;
Console.WriteLine("10 & 20 = {0}", andResult);
// “或”运算
int orResult = varA | varB;
Console.WriteLine("10 | 20 = {0}", orResult);
// “异或”运算
int notorResult = varA ^ varB;
Console.WriteLine("10 ^ 20 = {0}", orResult);
// “求补”运算
Console.WriteLine("~ {0:x8} = {1:x8}", varA, ~varA);
// 按位右移
Console.WriteLine("{0:x8} >> 3 = {1}", varA, varA >> 3);
// 按位左移
Console.WriteLine("{0:x8} << 3 = {1}", varA, varA << 3);
}
}
运行结果是:
10&20=0
10|20=30
10^20=30
~0000000a=fffffff5
0000000a>>3=1
0000000a<<3=80
不懂啊,哪位大哥大姐能给我解释一下啊,越具体越好啊
using System;
class MyClass
{
public static void Main()
{
int varA = 10; //二进制为 00001010
int varB = 20; //二进制为 00010100
// “与”运算
int andResult = varA & varB;
Console.WriteLine("10 & 20 = {0}", andResult);
// “或”运算
int orResult = varA | varB;
Console.WriteLine("10 | 20 = {0}", orResult);
// “异或”运算
int notorResult = varA ^ varB;
Console.WriteLine("10 ^ 20 = {0}", orResult);
// “求补”运算
Console.WriteLine("~ {0:x8} = {1:x8}", varA, ~varA);
// 按位右移
Console.WriteLine("{0:x8} >> 3 = {1}", varA, varA >> 3);
// 按位左移
Console.WriteLine("{0:x8} << 3 = {1}", varA, varA << 3);
}
}
运行结果是:
10&20=0
10|20=30
10^20=30
~0000000a=fffffff5
0000000a>>3=1
0000000a<<3=80
不懂啊,哪位大哥大姐能给我解释一下啊,越具体越好啊