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

    java中位运算

    System.out.println(6&3); //2     0010  且
            System.out.println(6|3); //7     0111  或
            System.out.println(6^3); //5     0101  异或
            System.out.println(6>>2); //1    0000  将0110 向右移动两位
            System.out.println(-6>>2); //-2    0000  将0110 向右移动两位
            System.out.println(6<<3); //48   0011 0000 向左移动三位 6*2^3
            System.out.println(6>>>2); //1 Java也添加了一种“无符号”右移位运算符(>>>),它使用了“零扩展”:无论正负,都在高位插入0。这一运算符是C或C++没有的
            System.out.println(-6>>>2); //1073741822 Java也添加了一种“无符号”右移位运算符(>>>),它使用了“零扩展”:无论正负,都在高位插入0。这一运算符是C或C++没有的
            System.out.println(Integer.toBinaryString(-6)); //11111111111111111111111111111010
            System.out.println(Integer.toBinaryString(6)); //110
            System.out.println(Integer.toBinaryString(-6>>2)); //有符号 11111111111111111111111111111110 换算得 -2 (求反码,某尾部加+1,十进制前加-)
            System.out.println(Integer.toBinaryString(-6>>>2)); //无符号 111111111111111111111111111110 1073741822
    

      

  • 相关阅读:
    CD4051
    sbit和sfr的定义
    EEPROM与FLASH的区别
    九LWIP学习笔记之最后的战役
    八LWIP学习笔记之用户编程接口(NETCONN)
    七LWIP学习笔记之传输控制协议(TCP)
    六LWIP学习笔记之用户数据报协议(UDP)
    java实现二叉查找树
    线程的锁对象
    MAP
  • 原文地址:https://www.cnblogs.com/han-guang-xue/p/13878818.html
Copyright © 2011-2022 走看看