> 4 & 0x0F"?-6ren"> > 4 & 0x0F"?-我完全不明白这段代码在做什么,有人可以解释一下吗? long input; //just here to show the type, assume it has a value stored un-6ren">
gpt4 book ai didi

c++ - 这是在做什么 : "input >> 4 & 0x0F"?

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:58:21 25 4
gpt4 key购买 nike

我完全不明白这段代码在做什么,有人可以解释一下吗?

long input;  //just here to show the type, assume it has a value stored
unsigned int output( input >> 4 & 0x0F );

谢谢

最佳答案

将输入向右移动 4 位,然后用低 4 位屏蔽。

以16位数字为例:(点只是为了视觉分隔)

1001.1111.1101.1001 >> 4 = 0000.1001.1111.1101

0000.1001.1111.1101 & 0x0F = 1101 (or 0000.0000.0000.1101 to be more explicit)

关于c++ - 这是在做什么 : "input >> 4 & 0x0F"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12515412/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com