zoukankan      html  css  js  c++  java
  • Bit operator: Left shift and Right shift (Signed or unsigned? )

    No matter left shift or right shift, the result's sign should always be the same as its left operand.
    By default, const numbers in C/C++ is signed.
    -Wsign-compare
    {
         unsigned int j = 3;
         int k = 5;
         
         if (j == (1 << (j)));  //warning: comparison between signed and unsigned integer expressions.
         if (j == (((unsigned int)1) << (j)));
         if (k == (1 << (k)));
         if (k == (((unsigned int)1) << (k))); //warning: comparison between signed and unsigned integer expressions.
         if (j == (j >> 1));
         if (j == (k >> 1)); //warning: comparison between signed and unsigned integer expressions.
         if (k == (k >> 1));
         if (k == (j >> 1)); //warning: comparison between signed and unsigned integer expressions.
    }
  • 相关阅读:
    哈希表
    fastcgi 分布式
    环形队列实现
    队列--双链表实现
    lighttpd fastcgi的搭建
    vim 常用命令
    命令行解析getopt_long
    规范打log
    apt-get &dpkg
    Linux syslog 学习
  • 原文地址:https://www.cnblogs.com/liguangsunls/p/6718086.html
Copyright © 2011-2022 走看看