C#中的按位右移运算符
按位运算符对位进行运算并执行逐位运算。在按位右移运算符中,左操作数的值向右移动右操作数指定的位数。
在下面的代码中,我们有值-
60 i.e. 0011 1100
右移%减号;
c = a >> 2;
右移两次后转换为15-
15 i.e. 0000 1111
示例
您可以尝试运行以下代码以在C#中实现按位右移运算符-
using System;
using System.Collections.Generic;
using System.Text;
namespace Demo {
class toBinary {
static void Main(string[] args) {
int a = 60; /* 60 = 0011 1100 */
int b = 0;
c = a >> 2; /* 15 = 0000 1111 */
Console.WriteLine("Value of b is {0}", b);
Console.ReadLine();
}
}
}热门推荐
10 新人红包祝福语简短精辟
11 幼师给毕业祝福语简短
12 生日高考祝福语妹妹简短
13 下飞机祝福语简短英文
14 元宵发客户祝福语简短
15 爸妈金婚文案祝福语简短
16 新郎朋友红包祝福语简短
17 虎年五一祝福语大全简短
18 出阁宴祝福语姐姐简短