<<= 代表什么(在 C 中)? [英] What does <<= represent (in C)?

查看:83
本文介绍了<<= 代表什么(在 C 中)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所说,我对 <<= 所代表的含义感到有些困惑.我知道 << 是一个移位运算符,但这是我第一次看到 = 和它一起.有什么说明吗?

As the title says I am a bit confused by what <<= represents. I know << is a shift operator, but this is the first time I saw a = along with it. Any clarifications?

示例代码:

#include <stdio.h> 
main() { 
  unsigned int i, s; 
  for( s = i = 0; i <= 7; i++){ 
    switch (i%3) { 
      case 0: i++; 
      case 1: i <<= (7 & (i + 1)) | ((i + 2) & 6); s += i; break; 
      case 2: i += (i ^ i) | 1 ; continue; 
    } 
    s++; 
  } 
  printf("%d\n", s); 
} 

推荐答案

AFAIK >>= 是相同"的操作.你可以打电话给

AFAIK >>= is the "same" operation. you can either call

i = i << 4;

i <<= 4;

效果一样.

就像 i = i + 5;i += 5;

这篇关于&lt;&lt;= 代表什么(在 C 中)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆