Bitwise shift left and right in the same statement

后端 未结 3 1047
再見小時候
再見小時候 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:26

    Yes, it is a valid syntax. It is a valid syntax also for signed int i1, in which case you can achieve filling the 'upper part' of the value with the bit from a chosen position.

提交回复
热议问题