zoukankan      html  css  js  c++  java
  • c#中位运算符的运用(转载)

    using System;
    using System.Collections.Generic;
    using System.Text;

    namespace weiyunsuan
    {
        class Program
        {
            static void Main(string[] args)
            {
                int x = 5;
                int y = 3;
                // & | ^ ~

                //&两个都是一才为1
                int z = x & y;
                //x=0101
                //y=0011
                //&-----------
                //z=0001(2)
                Console.WriteLine(z);

                //|两个有一个为一就为1
                z = x | y;
                //x=0101
                //y=0011
                //z=0111(7)
                Console.WriteLine(z);

                //^两个不同就为1
                z = x ^ y;
                //x=0101
                //y=0011
                //z=0110(6)
                Console.WriteLine(z);

                //~一元运算符相反值
                z = ~x;
                //x=0101
                //z=1010
                Console.WriteLine(z);

                z = x>>2;
                //x=0101
                //z=0001(1)
                Console.WriteLine(z);

                z = x << 2;
                //x=00010100
                //z=00010100
                Console.WriteLine(z);

                int x = 5;
                int y = 3;
                // & | ^ ~

                //&两个都是一才为1
                int z = x & y;
                //x=0101
                //y=0011
                //&-----------
                //z=0001(2)
                Console.WriteLine(z);

                //|两个有一个为一就为1
                z = x | y;
                //x=0101
                //y=0011
                //z=0111(7)
                Console.WriteLine(z);

                //^两个不同就为1
                z = x ^ y;
                //x=0101
                //y=0011
                //z=0110(6)
                Console.WriteLine(z);

                //~一元运算符相反值
                z = ~x;
                //x=0101
                //z=1010(-6)
                Console.WriteLine(z);


                z = x >> 2;
                //x=0101
                //z=0001(1)
                Console.WriteLine(z);

                z = x << 2;
                //x=00010100
                //z=00010100
                Console.WriteLine(z);

            }
        }
    }

  • 相关阅读:
    u3d 地形 U3d terrain
    u3d 鼠标点击位置,物体移动过去。 U3d mouse clicks position, objects move past.
    u3d 逐个点运动,路径运动。 U3d one by one, path motion.
    u3d 楼梯,圆环,椭圆,直线运动。世界坐标。点击。U3d stair, ring, ellipse, linear motion.World coordinates.Click .
    u3d 元件的克隆 Cloning of u3d components
    u3d 创建元件 预制件 U3d creates component prefabricated parts
    Unity3D 入门 游戏开发 Unity3D portal game development
    Egret 之 消除游戏 开发 PART 6 Egret elimination game development PART 6
    [BZOJ1101][POI2007]Zap
    [BZOJ2820]YY的GCD
  • 原文地址:https://www.cnblogs.com/zpc870921/p/2662572.html
Copyright © 2011-2022 走看看