zoukankan      html  css  js  c++  java
  • java中的位运算


    public class weiyunsuan {
        
    public static void main(String[] args) {
            
    int a=-6;//          1111 1111 1111 1111 1111 1111 1111 1010
            int b=3;//           0000 0000 0000 0000 0000 0000 0000 0011
            int c=6//          0000 0000 0000 0000 0000 0000 0000 0110
            zuoyi(a, b);//-48    1111 1111 1111 1111 1111 1111 1101 0000
            youyi(a, b);//-1     1111 1111 1111 1111 1111 1111 1111 1111
            wufuhaoyouyi(a, b);//0001 1111 1111 1111 1111 1111 1111 1111
            zuoyi(c, b);//48     0000 0000 0000 0000 0000 0000 0011 0000
            youyi(c, b);//0      0000 0000 0000 0000 0000 0000 0000 0000
            wufuhaoyouyi(c, b);//0000 0000 0000 0000 0000 0000 0000 0000
            yu(a, b);//2         0000 0000 0000 0000 0000 0000 0000 0010
            huo(a, b);//-5       1111 1111 1111 1111 1111 1111 1111 1011
            fei(a);//5           0000 0000 0000 0000 0000 0000 0000 0101
            yihuo(a, b);//-7     1111 1111 1111 1111 1111 1111 1111 1001
        }
        
    public static void zuoyi(int a,int b){
            System.out.println(a
    <<b);
        }
        
    public static void youyi(int a,int b){
            System.out.println(a
    >>b);
        }
        
    public static void wufuhaoyouyi(int a,int b){
            System.out.println(a
    >>>b);
        }
        
    public static void yu(int a,int b){
            System.out.println(a
    &b);
        }
        
    public static void huo(int a,int b){
            System.out.println(a
    |b);
        }
        
    public static void fei(int a){
            System.out.println(
    ~a);
        }
        
    public static void yihuo(int a,int b){
            System.out.println(a
    ^b);
        }
    }

  • 相关阅读:
    从远程仓库更新本地仓库
    git添加所有新文件
    删除远程仓库文件夹
    更新被驳回
    git安装和第一次提交过程
    JSONobject按照put顺序存储和读取
    Map 转 json格式 保留null值的解决办法
    Java对象转换Json的细节处理
    如何解析json格式的字符串
    json 拼装空list、object
  • 原文地址:https://www.cnblogs.com/zhonghan/p/1442320.html
Copyright © 2011-2022 走看看