小编Pra*_*har的帖子

sizeof运算符在按位和在C中失败

感谢您的回应,祖%符好工作与sizeof操作符,大小也被印好的x和y的值.但是当我将所有这些说明符更改为%lld时,它应该打印实际的x和y值(因为它们很长),它会打印一些随机垃圾值.

    #include<stdio.h>

    int main()
    {
      long long x=500000000007;
      long long y=1;
      printf("size of x : %lld,x = %lld, size of y : %lld, y : %lld\n",sizeof(x),x,sizeof(y),y); 

      if(x & y)
      {
        printf("ODD IT IS :), x&1 = %lld, size of x&1 = %lld\n",x&y,sizeof(x&y) );//<--- this line
      }



      printf("After If statement ---> size of x : %lld,x = %lld\n",sizeof(x),x); 

      return 0;
    }

    Output on linux 32 bit system(Ubuntu) using gcc compiler
      size of x : 7661335479756783624,x = 34359738484, size of y : …
Run Code Online (Sandbox Code Playgroud)

c sizeof bitwise-and

-1
推荐指数
1
解决办法
158
查看次数

标签 统计

bitwise-and ×1

c ×1

sizeof ×1