doucan8246326
2015-04-10 17:04
浏览 258
已采纳

使用golang中的位移将位从32位无符号整数中取出

I have a 32bit unsigned integer and I want to divide it in 3 uint16 values. I want first 15bits, then 2 bits and then last 15 bits.

I am trying something like -

val >> 17
val >> 2
val >> 15

apart from first value, other 2 are not right and I know that but now able to figure out how to fix that?

Go play ground

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

2条回答 默认 最新

相关推荐 更多相似问题