Bitwise shift left and right in the same statement

后端 未结 3 1139
再見小時候
再見小時候 2021-01-25 12:49

Is char c2=i1<<8>>24; valid C syntax? (Where i1 is and unsigned integer) Additionally, will it yield the result of shifting i1

3条回答
  •  孤独总比滥情好
    2021-01-25 13:49

    As others have noted, it's valid syntax. You can achieve the effect that I believe is desired more understandably and portably with:

    unsigned char c2 = (i1 & 0xff0000) >> 16;
    

提交回复
热议问题