json-tutorial icon indicating copy to clipboard operation
json-tutorial copied to clipboard

[Tutorial 04] 关于「& 0xFF」的问题

Open Haceau-Zoac opened this issue 3 years ago • 1 comments

3. UTF-8 编码 处,代码里有 (u >> 12) & 0xFF,0xFF = 11111111,对它进行逻辑与操作和不进行不一样吗?

Haceau-Zoac avatar Jul 04 '22 02:07 Haceau-Zoac

不等价,0xFF保证获取最低八位 以u(24bit)为例,u >> 12后,u还剩下12bit,而(u >> 12) & 0xFF 只有低8bit

zjb1001 avatar Jan 02 '24 09:01 zjb1001