zoukankan      html  css  js  c++  java
  • 获取数据到字节-位的显示

      // Int32 num1 = 4;
                //long num1 = 4;
                Int64 num1 = 4;
     
     
     
                num1 = num1 << 1;//右移动
     
     
                byte[] bs = BitConverter.GetBytes(num1);
     
                BitArray arr = new BitArray(bs);
     
                //设置第四位为打开状态
                //arr[4] = true;
               
     
                var sb = new StringBuilder();
                for (int i = arr.Length-1; i >=0; i--)
                {
                    if (arr[i] == true )
                    {
                        sb.Append("1");
                    }
                    else
                    {
                        sb.Append("0");
                    }
                }
     
               
     
               
     
                Console.WriteLine(string.Format("Length is  :{0}",arr.Length));
                Console.WriteLine(sb.ToString());
     
     
     
     
                Console.WriteLine(Convert.ToInt64(sb.ToString(),2));
                Console.ReadKey();
  • 相关阅读:
    cf B. Vasily the Bear and Fly
    hdu 3339 In Action
    hdu 六度分离
    cf A. Vasily the Bear and Triangle
    cf C. Secrets
    2.19学习笔记|2.20学习笔记
    VAE代码学习
    2.9日学习记录
    deconvolution反卷积(待学习)
    gamma分布学习
  • 原文地址:https://www.cnblogs.com/micro-chen/p/4195612.html
Copyright © 2011-2022 走看看